mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-09-29 22:11:22 +00:00
discard least recently used items if cache saving fails until empty
fixes https://github.com/bigskysoftware/htmx/issues/377
This commit is contained in:
parent
11287d924b
commit
36e6020942
12
src/htmx.js
12
src/htmx.js
@ -1418,10 +1418,14 @@ return (function () {
|
||||
while (historyCache.length > htmx.config.historyCacheSize) {
|
||||
historyCache.shift();
|
||||
}
|
||||
try {
|
||||
localStorage.setItem("htmx-history-cache", JSON.stringify(historyCache));
|
||||
} catch (e) {
|
||||
triggerErrorEvent(getDocument().body, "htmx:historyCacheError", {cause:e})
|
||||
while(historyCache.length > 0){
|
||||
try {
|
||||
localStorage.setItem("htmx-history-cache", JSON.stringify(historyCache));
|
||||
return;
|
||||
} catch (e) {
|
||||
triggerErrorEvent(getDocument().body, "htmx:historyCacheError", {cause:e, cache: historyCache})
|
||||
historyCache.shift(); // shrink the cache and retry
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user