@cocreate/local-storage
Advanced tools
Comparing version 1.14.2 to 1.14.3
@@ -0,1 +1,8 @@ | ||
## [1.14.3](https://github.com/CoCreate-app/CoCreate-local-storage/compare/v1.14.2...v1.14.3) (2024-04-26) | ||
### Bug Fixes | ||
* error handling of QuotaExceededError ([58ee966](https://github.com/CoCreate-app/CoCreate-local-storage/commit/58ee966f8b933a4950c0d88a54a8f737eaf3ffac)) | ||
## [1.14.2](https://github.com/CoCreate-app/CoCreate-local-storage/compare/v1.14.1...v1.14.2) (2024-02-14) | ||
@@ -2,0 +9,0 @@ |
{ | ||
"name": "@cocreate/local-storage", | ||
"version": "1.14.2", | ||
"version": "1.14.3", | ||
"description": "A Simple component similar to CoCreate-input & CoCreate-fetch which Save and fetch data for inputs, textarea, selects from localstorage. Easily configured using HTML5 attributes and/or JavaScript API", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -85,7 +85,15 @@ import observer from '@cocreate/observer'; | ||
setItem: function (key, value) { | ||
// Set the value of the item. | ||
if (this.support) | ||
window.localStorage.setItem(key, value); | ||
else | ||
this.storage.set(key, value) | ||
try { | ||
if (this.support) | ||
window.localStorage.setItem(key, value); | ||
else | ||
this.storage.set(key, value); | ||
} catch (error) { | ||
if (error instanceof DOMException && (error.code === 22 || error.code === 1014 || error.name === 'QuotaExceededError' || error.name === 'NS_ERROR_DOM_QUOTA_REACHED')) { | ||
// TODO: create a fallback method, perhaps setting in indexeddb if above a specific size | ||
console.log('Local storage limit exceeded. Falling back to IndexedDB.'); | ||
} else { | ||
console.error('Error setting item:', error); | ||
} | ||
} | ||
}, | ||
@@ -92,0 +100,0 @@ |
107543
89
314
6