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

@cocreate/element-prototype

Package Overview
Dependencies
Maintainers
1
Versions
144
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cocreate/element-prototype - npm Package Compare versions

Comparing version 1.22.3 to 1.23.0

13

CHANGELOG.md

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

# [1.23.0](https://github.com/CoCreate-app/CoCreate-element-prototype/compare/v1.22.3...v1.23.0) (2024-05-08)
### Bug Fixes
* removed utils ([71a5003](https://github.com/CoCreate-app/CoCreate-element-prototype/commit/71a5003bf7ca85b704140e10b132d8728600f518))
### Features
* update attibutes using keyObperators on storage change or event updateAttributes ([5a33bbd](https://github.com/CoCreate-app/CoCreate-element-prototype/commit/5a33bbd90ba6564a8ee9583935e5e0c1663d5d39))
* valueType boolean ([7f6777f](https://github.com/CoCreate-app/CoCreate-element-prototype/commit/7f6777fb8ab6417d8b920cfbd2135c402423b6d6))
## [1.22.3](https://github.com/CoCreate-app/CoCreate-element-prototype/compare/v1.22.2...v1.22.3) (2024-04-29)

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

6

package.json
{
"name": "@cocreate/element-prototype",
"version": "1.22.3",
"version": "1.23.0",
"description": "A simple element-prototype component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.",

@@ -60,5 +60,3 @@ "keywords": [

},
"dependencies": {
"@cocreate/utils": "^1.33.6"
}
"dependencies": {}
}
// Store a reference to the original getAttribute function
const originalGetAttribute = Element.prototype.getAttribute;
const attributes = new Map()
window.addEventListener('storage', updateAttributes);
window.addEventListener('updateAttributes', function (e) {
updateAttributes(e.detail);
});
function updateAttributes(e) {
const keys = ['organization_id', 'user_id', 'clientId', 'session_id'];
if (keys.includes(e.key)) {
let attr = attributes.get(e.key) || []
for (let attribute of attr) {
attribute.element.setAttribute(attribute.name, e.newValue)
}
}
}
// Override the getAttribute function

@@ -8,15 +24,27 @@ Element.prototype.getAttribute = function (name) {

if (value === '$organization_id')
value = localStorage.getItem('organization_id')
else if (value === '$user_id')
value = localStorage.getItem('user_id')
else if (value === '$clientId')
value = localStorage.getItem('clientId')
else if (value === '$session_id')
value = localStorage.getItem('session_id')
else if (value === '$innerWidth')
const localKeys = {
'$organization_id': 'organization_id',
'$user_id': 'user_id',
'$clientId': 'clientId',
'$session_id': 'session_id'
};
if (localKeys[value]) {
let newValue = localStorage.getItem(localKeys[value]);
if (!attributes.has(localKeys[value])) {
attributes.set(localKeys[value], []);
}
attributes.get(localKeys[value]).push({
element: this,
name,
value: newValue
});
value = newValue
} else if (value === '$innerWidth') {
value = window.innerWidth
else if (value === '$innerHeight')
} else if (value === '$innerHeight') {
value = window.innerHeight
else if (typeof value === 'string') {
} else if (typeof value === 'string') {
if (value.startsWith('$search')) {

@@ -23,0 +51,0 @@ const searchParams = new URLSearchParams(window.location.search);

@@ -149,2 +149,9 @@ const storage = new Map()

if (valueType === 'boolean') {
if (!value || value === 'fasle')
return false
else
return true
}
if (value === '$organization_id')

@@ -151,0 +158,0 @@ value = localStorage.getItem('organization_id')

@@ -1,2 +0,1 @@

import { getAttributes } from '@cocreate/utils';
import { storage } from './getValue';

@@ -18,2 +17,6 @@

const setValue = (el, value, dispatch) => {
if (value === '$false') {
return dispatchEvents(el, dispatch)
};
if (value === null || value === undefined) return;

@@ -40,6 +43,5 @@ if (el.hasAttribute('component') || el.hasAttribute('plugin'))

// TODO: attribute config undefined when used with onload-value
let isCrdt = el.getAttribute('crdt') // getAttributes(el)
// if (isCrdt == null || isCrdt == undefined)
// isCrdt = el.getAttribute('crdt')
if (isCrdt == "true" || el.type === 'file') return;
let isCrdt = el.getAttribute('crdt')
if (isCrdt == "true" || el.type === 'file')
return;

@@ -46,0 +48,0 @@ if (el.type == 'checkbox') {

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