html-element-property-mixins
Advanced tools
Comparing version 0.9.2 to 0.9.3
{ | ||
"name": "html-element-property-mixins", | ||
"version": "0.9.2", | ||
"version": "0.9.3", | ||
"description": "A collection of mixins extending HTMLElement with properties.", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -16,3 +16,3 @@ export const ObservedProperties = (SuperClass) => class extends SuperClass { | ||
this.constructor.__initialPropertyValues = new Map(); | ||
this.constructor.observedProperties.map(propName => this.constructor.__initialPropertyValues.set(propName, this[propName])); | ||
(this.constructor.observedProperties || []).map(propName => this.constructor.__initialPropertyValues.set(propName, this[propName])); | ||
} | ||
@@ -27,3 +27,4 @@ | ||
static __initProperties() { | ||
const observedProps = this.constructor.observedProperties || {}; | ||
this.constructor.__propertyAccessors = {}; | ||
const observedProps = this.constructor.observedProperties || []; | ||
observedProps.map(propName => this.constructor.__initProperty.call(this, propName)); | ||
@@ -33,2 +34,3 @@ } | ||
static __initProperty(propName) { | ||
this.constructor.__propertyAccessors[propName] = this.__getPropertyDescriptor(this, propName); | ||
Object.defineProperty(this, propName, { | ||
@@ -41,3 +43,3 @@ set(val) { this.constructor.__setProperty.call(this, propName, val); }, | ||
static __getProperty(propName) { | ||
const customAccessors = Object.getOwnPropertyDescriptors(this.constructor.prototype)[propName] || {}; | ||
const customAccessors = this.constructor.__propertyAccessors[propName] || {}; | ||
if(customAccessors.get) return customAccessors.get.call(this, propName); | ||
@@ -48,3 +50,3 @@ return this[`#${propName}`]; | ||
static __setProperty(propName, newValue) { | ||
const customAccessors = Object.getOwnPropertyDescriptors(this.constructor.prototype)[propName] || {}; | ||
const customAccessors = this.constructor.__propertyAccessors[propName] || {}; | ||
const oldValue = this[propName]; | ||
@@ -61,2 +63,7 @@ if(customAccessors.set) customAccessors.set.call(this, newValue); | ||
__getPropertyDescriptor(obj, key) { | ||
if(!obj) return; | ||
return Object.getOwnPropertyDescriptor(obj, key) || this.__getPropertyDescriptor(Object.getPrototypeOf(obj), key) | ||
} | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31965
351