Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cocreate/local-storage

Package Overview
Dependencies
Maintainers
1
Versions
205
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cocreate/local-storage - npm Package Compare versions

Comparing version 1.14.4 to 1.15.0

13

CHANGELOG.md

@@ -0,1 +1,14 @@

# [1.15.0](https://github.com/CoCreate-app/CoCreate-local-storage/compare/v1.14.4...v1.15.0) (2024-05-08)
### Bug Fixes
* action property typo ([f17a85f](https://github.com/CoCreate-app/CoCreate-local-storage/commit/f17a85f7c4221044af7c0f7c92004beae7269f10))
* dispatch event if value null ([9975383](https://github.com/CoCreate-app/CoCreate-local-storage/commit/99753839b55a54497e91e5d29ad17585b1cb83e3))
### Features
* dispatch updateAttributes event for operators ([ee86894](https://github.com/CoCreate-app/CoCreate-local-storage/commit/ee86894c119e5d375abe681ab03df5a9999860b9))
## [1.14.4](https://github.com/CoCreate-app/CoCreate-local-storage/compare/v1.14.3...v1.14.4) (2024-04-29)

@@ -2,0 +15,0 @@

2

package.json
{
"name": "@cocreate/local-storage",
"version": "1.14.4",
"version": "1.15.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",

@@ -5,0 +5,0 @@ "keywords": [

import observer from '@cocreate/observer';
import action from '@cocreate/actions'
import actions from '@cocreate/actions'

@@ -42,3 +42,16 @@ const CoCreateLocalStorage = {

initElement: function (element) {
this.getItem(element)
let value = this.getItem(element)
if (value)
element.setValue(value)
else {
let inputEvent = new CustomEvent('input', {
bubbles: true
});
Object.defineProperty(inputEvent, 'target', {
writable: false,
value: element
});
element.dispatchEvent(inputEvent);
}
element.addEventListener('input', (e) => {

@@ -87,5 +100,15 @@ let isRealtime = element.getAttribute('realtime')

try {
if (this.support)
if (this.support) {
const oldValue = localStorage.getItem(key);
window.localStorage.setItem(key, value);
else
const keys = ['organization_id', 'user_id', 'clientId', 'session_id'];
if (keys.includes(key)) {
const updateEvent = new CustomEvent('updateAttributes', {
detail: { key, newValue: value, oldValue }
});
window.dispatchEvent(updateEvent);
}
} else
this.storage.set(key, value);

@@ -114,8 +137,8 @@ } catch (error) {

/**
* @param btn
* @param action
*
* @return { undefined } No return
*/
runStorage: async function (btn) {
const form = btn.form;
runStorage: async function (action) {
const form = action.form;
// If the form is not a form return false.

@@ -184,18 +207,19 @@ if (!form) return;

action.init({
name: "localStorage",
endEvent: "localStorage",
callback: (data) => {
CoCreateLocalStorage.runStorage(data.element)
actions.init(
{
name: "localStorage",
endEvent: "localStorage",
callback: (data) => {
CoCreateLocalStorage.runStorage(data)
},
},
})
{
name: "localStorageRemove",
endEvent: "localStorageRemoved",
callback: (data) => {
CoCreateLocalStorage.runStorage(data)
}
}
)
action.init({
name: "localStorageRemove",
endEvent: "localStorageRemoved",
callback: (data) => {
CoCreateLocalStorage.runStorage(data.element)
},
})
observer.init({

@@ -202,0 +226,0 @@ observe: ['addedNodes'],

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc