@cocreate/local-storage
Advanced tools
Comparing version 1.11.1 to 1.12.0
@@ -0,1 +1,13 @@ | ||
# [1.12.0](https://github.com/CoCreate-app/CoCreate-local-storage/compare/v1.11.1...v1.12.0) (2023-11-25) | ||
### Bug Fixes | ||
* update nav, edit button and css path ([2bc7891](https://github.com/CoCreate-app/CoCreate-local-storage/commit/2bc78915b8bfb1d06ae109419acdbcd392c0f9c4)) | ||
### Features | ||
* upgrade dependencies for latest features and fixes ([85889c5](https://github.com/CoCreate-app/CoCreate-local-storage/commit/85889c578d45a5394cd606eabd8cc2ce59dd351a)) | ||
## [1.11.1](https://github.com/CoCreate-app/CoCreate-local-storage/compare/v1.11.0...v1.11.1) (2023-11-22) | ||
@@ -2,0 +14,0 @@ |
{ | ||
"name": "@cocreate/local-storage", | ||
"version": "1.11.1", | ||
"version": "1.12.0", | ||
"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", | ||
@@ -61,5 +61,5 @@ "keywords": [ | ||
"dependencies": { | ||
"@cocreate/actions": "^1.12.4", | ||
"@cocreate/observer": "^1.12.0" | ||
"@cocreate/actions": "^1.13.0", | ||
"@cocreate/observer": "^1.13.0" | ||
} | ||
} |
@@ -8,5 +8,2 @@ import observer from '@cocreate/observer'; | ||
/** | ||
* Listen for storage events and update elements if needed. This is called on window. storage and when it's time to get / set data | ||
*/ | ||
init: function () { | ||
@@ -16,12 +13,11 @@ const self = this | ||
this.initElements(elements) | ||
/** | ||
* @param e | ||
*/ | ||
window.addEventListener('storage', function (e) { | ||
elements = document.querySelectorAll(`[localstorage-get="${e.key}"]`) | ||
for (let element of elements) { | ||
// TODO: return if localstorage-selector, etc... | ||
// - Decide how best to handle, considering localstorage is also handled by event. | ||
if (element.hasAttribute('localstorage-attribute') || element.hasAttribute('localstorage-value') || element.hasAttribute('localstorage-key')) | ||
return | ||
let value = self.getItem(e.key) | ||
// Set the value of the element. | ||
if (value != null) { | ||
@@ -35,4 +31,5 @@ element.setValue(value) | ||
/** | ||
* @param elements | ||
*/ | ||
* Initializes a collection of elements. | ||
* @param {Array<Element>} elements - An array of elements to be initialized. | ||
*/ | ||
initElements: function (elements) { | ||
@@ -44,6 +41,5 @@ for (let element of elements) | ||
/** | ||
* @param element | ||
* | ||
* @return { Object } The binding | ||
*/ | ||
* Initializes a single element. | ||
* @param {Element} element - The element to initialize. This function expects an 'Element' type. | ||
*/ | ||
initElement: function (element) { | ||
@@ -50,0 +46,0 @@ this.getItem(element) |
Sorry, the diff of this file is not supported yet
105407
296
Updated@cocreate/actions@^1.13.0
Updated@cocreate/observer@^1.13.0