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

html-element-property-mixins

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-element-property-mixins - npm Package Compare versions

Comparing version 0.10.9 to 0.10.10

2

package.json
{
"name": "html-element-property-mixins",
"version": "0.10.9",
"version": "0.10.10",
"description": "A collection of mixins extending HTMLElement with properties.",

@@ -5,0 +5,0 @@ "main": "src/index.js",

export const DOMProperties = (SuperClass) => class extends SuperClass {
constructor() {
super();
this.constructor.__saveInitialAttributeValues.call(this);
}
connectedCallback() {
super.connectedCallback && super.connectedCallback();
this.constructor.__setInitialAttributeValues.call(this);
}
static get observedAttributes() {

@@ -27,16 +17,2 @@ const observedAttributes = [];

static __saveInitialAttributeValues() {
const attrValues = new Map();
const attributes = Array.from(this.attributes);
for(var i in attributes) attrValues.set(attributes[i], this.getAttribute(attributes[i]))
this.__initialAttributeValues = attrValues;
}
static __setInitialAttributeValues() {
const attrValues = this.__initialAttributeValues;
attrValues.forEach((val, attrName) => {
if(val !== null) this.setAttribute(attrName, val)
})
}
static __getPropertyNameByAttributeName(attrName) {

@@ -43,0 +19,0 @@ const attributeNames = this.constructor.propertyAttributeNames;

@@ -10,3 +10,2 @@ export const ObservedProperties = (SuperClass) => class extends SuperClass {

connectedCallback() {
this.constructor.__propertiesInited = true;
super.connectedCallback && super.connectedCallback();

@@ -13,0 +12,0 @@ this.constructor.__setInitialPropertyValues.call(this);

export const ReflectedProperties = (SuperClass) => class extends SuperClass {
connectedCallback() {
super.connectedCallback();
for(var i in this.constructor.reflectedProperties) {
const propName = this.constructor.reflectedProperties[i];
const attrName = this.constructor.__getAttributeNameByPropertyName.call(this, propName);
this.constructor.__setDOMAttribute.call(this, attrName, propName, this[propName]);
}
}
propertyChangedCallback(propName, oldValue, newValue) {
super.propertyChangedCallback && super.propertyChangedCallback(propName, oldValue, newValue);
if(!this.isConnected) return;
const reflectedProps = this.constructor.reflectedProperties || {};
const attrReflects = reflectedProps.indexOf(propName) !== -1;
if(!attrReflects) return;
const attrName = this.constructor.__getAttributeNameByPropertyName.call(this, propName);
if(!this.isConnected) return;
if(!this.constructor.__propertiesInited) return;
this.constructor.__setDOMAttribute.call(this, attrName, propName, newValue);

@@ -23,3 +33,3 @@ }

static __getAttributeNameByPropertyName(propName) {
const reflectedProps = this.constructor.reflectedProperties || {};
const reflectedProps = this.constructor.reflectedProperties || [];
const attrNames = this.constructor.propertyAttributeNames || {};

@@ -26,0 +36,0 @@ if(reflectedProps.indexOf(propName) === -1) return;

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