use two fields for cache, so we don't need to parse JSON
This commit is contained in:
parent
77f82601aa
commit
639a5dd3d6
@ -67,7 +67,8 @@ function loadStyleSheets(callback) {
|
|||||||
|
|
||||||
function loadStyleSheet(sheet, callback) {
|
function loadStyleSheet(sheet, callback) {
|
||||||
var css = typeof(localStorage) !== "undefined" && localStorage.getItem(sheet.href);
|
var css = typeof(localStorage) !== "undefined" && localStorage.getItem(sheet.href);
|
||||||
var styles = css && JSON.parse(css);
|
var timestamp = typeof(localStorage) !== "undefined" && localStorage.getItem(sheet.href + ':timestamp');
|
||||||
|
var styles = { css: css, timestamp: timestamp };
|
||||||
|
|
||||||
xhr(sheet.href, function (data, lastModified) {
|
xhr(sheet.href, function (data, lastModified) {
|
||||||
if (styles && (new(Date)(lastModified).valueOf() ===
|
if (styles && (new(Date)(lastModified).valueOf() ===
|
||||||
@ -123,7 +124,8 @@ function createCSS(styles, sheet, lastModified) {
|
|||||||
|
|
||||||
// Don't update the local store if the file wasn't modified
|
// Don't update the local store if the file wasn't modified
|
||||||
if (lastModified && typeof(localStorage) !== "undefined") {
|
if (lastModified && typeof(localStorage) !== "undefined") {
|
||||||
localStorage.setItem(sheet.href, JSON.stringify({ timestamp: lastModified, css: styles }));
|
localStorage.setItem(sheet.href, styles);
|
||||||
|
localStorage.setItem(sheet.href + ':timestamp', lastModified);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user