Merge pull request #564 from artemave/better-dom-cache
push.js: cache dom before leaving the page, rather than right after loading it
This commit is contained in:
Коммит
d911d8fc71
|
@ -43,7 +43,6 @@
|
|||
}
|
||||
cacheMapping[data.id] = JSON.stringify(data);
|
||||
window.history.replaceState(data.id, data.title, data.url);
|
||||
domCache[data.id] = document.body.cloneNode(true);
|
||||
};
|
||||
|
||||
var cachePush = function () {
|
||||
|
@ -61,7 +60,7 @@
|
|||
delete cacheMapping[cacheBackStack.shift()];
|
||||
}
|
||||
|
||||
window.history.pushState(null, '', cacheMapping[PUSH.id].url);
|
||||
window.history.pushState(null, '', getCached(PUSH.id).url);
|
||||
|
||||
cacheMapping.cacheForwardStack = JSON.stringify(cacheForwardStack);
|
||||
cacheMapping.cacheBackStack = JSON.stringify(cacheBackStack);
|
||||
|
@ -244,6 +243,8 @@
|
|||
});
|
||||
}
|
||||
|
||||
cacheCurrentContent();
|
||||
|
||||
if (options.timeout) {
|
||||
options._timeout = setTimeout(function () { xhr.abort('timeout'); }, options.timeout);
|
||||
}
|
||||
|
@ -255,6 +256,10 @@
|
|||
}
|
||||
};
|
||||
|
||||
function cacheCurrentContent() {
|
||||
domCache[PUSH.id] = document.body.cloneNode(true);
|
||||
}
|
||||
|
||||
|
||||
// Main XHR handlers
|
||||
// =================
|
||||
|
|
Загрузка…
Ссылка в новой задаче