Comparing version 5.1.0 to 5.1.1
@@ -48,3 +48,3 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
} | ||
var propDefs = elem.constructor.props; | ||
var propDefs = elem.constructor._propsNormalised; | ||
for (var propName in propDefs) { | ||
@@ -51,0 +51,0 @@ var _propDefs$propName = propDefs[propName], |
@@ -16,11 +16,10 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function defineProps(constructor) { | ||
if (!('_props' in constructor)) { | ||
var _props = constructor.props; | ||
if (constructor.hasOwnProperty('_propsNormalised')) return; | ||
var props = constructor.props; | ||
keys(_props).forEach(function (name) { | ||
var func = _props[name]; | ||
if (typeof func !== 'function') func = prop(func); | ||
func({ constructor: constructor }, name); | ||
}); | ||
} | ||
keys(props).forEach(function (name) { | ||
var func = props[name]; | ||
if (typeof func !== 'function') func = prop(func); | ||
func({ constructor: constructor }, name); | ||
}); | ||
} | ||
@@ -48,11 +47,11 @@ | ||
// classes or share the instance anywhere where it's not intended to be shared explicitly in userland code. | ||
if (!constructor.hasOwnProperty('_props')) { | ||
constructor._props = {}; | ||
if (!constructor.hasOwnProperty('_propsNormalised')) { | ||
constructor._propsNormalised = {}; | ||
} | ||
// Cache the value so we can reference when syncing the attribute to the property. | ||
constructor._props[name] = normalised; | ||
constructor._propsNormalised[name] = normalised; | ||
if (normalised.attribute.source) { | ||
constructor.observedAttributes = normalised.attribute.source; | ||
constructor._observedAttributes.push(normalised.attribute.source); | ||
} | ||
@@ -83,7 +82,9 @@ | ||
export var withUpdate = function withUpdate() { | ||
var _class, _temp2; | ||
var Base = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : HTMLElement; | ||
return function (_Base) { | ||
_inherits(_class2, _Base); | ||
return _temp2 = _class = function (_Base) { | ||
_inherits(_class, _Base); | ||
function _class2() { | ||
function _class() { | ||
var _ref2; | ||
@@ -93,3 +94,3 @@ | ||
_classCallCheck(this, _class2); | ||
_classCallCheck(this, _class); | ||
@@ -100,10 +101,10 @@ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref2 = _class2.__proto__ || Object.getPrototypeOf(_class2)).call.apply(_ref2, [this].concat(args))), _this), _this._prevProps = {}, _this._prevState = {}, _this._state = {}, _temp), _possibleConstructorReturn(_this, _ret); | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref2 = _class.__proto__ || Object.getPrototypeOf(_class)).call.apply(_ref2, [this].concat(args))), _this), _this._prevProps = {}, _this._prevState = {}, _this._state = {}, _temp), _possibleConstructorReturn(_this, _ret); | ||
} | ||
_createClass(_class2, [{ | ||
_createClass(_class, [{ | ||
key: 'attributeChangedCallback', | ||
value: function attributeChangedCallback(name, oldValue, newValue) { | ||
if (_get(_class2.prototype.__proto__ || Object.getPrototypeOf(_class2.prototype), 'attributeChangedCallback', this)) { | ||
_get(_class2.prototype.__proto__ || Object.getPrototypeOf(_class2.prototype), 'attributeChangedCallback', this).call(this, name, oldValue, newValue); | ||
if (_get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), 'attributeChangedCallback', this)) { | ||
_get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), 'attributeChangedCallback', this).call(this, name, oldValue, newValue); | ||
} | ||
@@ -115,4 +116,4 @@ syncAttributeToProperty(this, name, newValue); | ||
value: function connectedCallback() { | ||
if (_get(_class2.prototype.__proto__ || Object.getPrototypeOf(_class2.prototype), 'connectedCallback', this)) { | ||
_get(_class2.prototype.__proto__ || Object.getPrototypeOf(_class2.prototype), 'connectedCallback', this).call(this); | ||
if (_get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), 'connectedCallback', this)) { | ||
_get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), 'connectedCallback', this).call(this); | ||
} | ||
@@ -184,6 +185,3 @@ this.triggerUpdate(); | ||
defineProps(this); | ||
return this._observedAttributes || []; | ||
}, | ||
set: function set(attrs) { | ||
this._observedAttributes = (this.observedAttributes || []).concat(attrs); | ||
return this._observedAttributes; | ||
} | ||
@@ -193,17 +191,11 @@ }, { | ||
get: function get() { | ||
return this._props || {}; | ||
return this._props; | ||
}, | ||
set: function set(props) { | ||
var _this5 = this; | ||
keys(props).forEach(function (name) { | ||
var func = props[name]; | ||
if (typeof func !== 'function') func = prop(func); | ||
func({ constructor: _this5 }, name); | ||
}); | ||
this._props = props; | ||
} | ||
}]); | ||
return _class2; | ||
}(Base); | ||
return _class; | ||
}(Base), _class._observedAttributes = [], _temp2; | ||
}; | ||
@@ -210,0 +202,0 @@ |
@@ -35,3 +35,3 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
} | ||
const propDefs = elem.constructor.props; | ||
const propDefs = elem.constructor._propsNormalised; | ||
for (let propName in propDefs) { | ||
@@ -38,0 +38,0 @@ const { attribute: { source }, deserialize } = propDefs[propName]; |
@@ -8,10 +8,9 @@ | ||
function defineProps(constructor) { | ||
if (!('_props' in constructor)) { | ||
const { props } = constructor; | ||
keys(props).forEach(name => { | ||
let func = props[name]; | ||
if (typeof func !== 'function') func = prop(func); | ||
func({ constructor }, name); | ||
}); | ||
} | ||
if (constructor.hasOwnProperty('_propsNormalised')) return; | ||
const { props } = constructor; | ||
keys(props).forEach(name => { | ||
let func = props[name]; | ||
if (typeof func !== 'function') func = prop(func); | ||
func({ constructor }, name); | ||
}); | ||
} | ||
@@ -37,11 +36,11 @@ | ||
// classes or share the instance anywhere where it's not intended to be shared explicitly in userland code. | ||
if (!constructor.hasOwnProperty('_props')) { | ||
constructor._props = {}; | ||
if (!constructor.hasOwnProperty('_propsNormalised')) { | ||
constructor._propsNormalised = {}; | ||
} | ||
// Cache the value so we can reference when syncing the attribute to the property. | ||
constructor._props[name] = normalised; | ||
constructor._propsNormalised[name] = normalised; | ||
if (normalised.attribute.source) { | ||
constructor.observedAttributes = normalised.attribute.source; | ||
constructor._observedAttributes.push(normalised.attribute.source); | ||
} | ||
@@ -70,3 +69,5 @@ | ||
export const withUpdate = (Base = HTMLElement) => { | ||
return class extends Base { | ||
var _class, _temp2; | ||
return _temp2 = _class = class extends Base { | ||
constructor(...args) { | ||
@@ -83,19 +84,11 @@ var _temp; | ||
defineProps(this); | ||
return this._observedAttributes || []; | ||
return this._observedAttributes; | ||
} | ||
static set observedAttributes(attrs) { | ||
this._observedAttributes = (this.observedAttributes || []).concat(attrs); | ||
} | ||
static get props() { | ||
return this._props || {}; | ||
return this._props; | ||
} | ||
static set props(props) { | ||
keys(props).forEach(name => { | ||
let func = props[name]; | ||
if (typeof func !== 'function') func = prop(func); | ||
func({ constructor: this }, name); | ||
}); | ||
this._props = props; | ||
} | ||
@@ -160,3 +153,3 @@ | ||
} | ||
}; | ||
}, _class._observedAttributes = [], _temp2; | ||
}; | ||
@@ -163,0 +156,0 @@ |
@@ -51,3 +51,3 @@ 'use strict'; | ||
} | ||
const propDefs = elem.constructor.props; | ||
const propDefs = elem.constructor._propsNormalised; | ||
for (let propName in propDefs) { | ||
@@ -54,0 +54,0 @@ var _propDefs$propName = propDefs[propName]; |
@@ -14,11 +14,10 @@ 'use strict'; | ||
function defineProps(constructor) { | ||
if (!('_props' in constructor)) { | ||
const props = constructor.props; | ||
if (constructor.hasOwnProperty('_propsNormalised')) return; | ||
const props = constructor.props; | ||
(0, _index.keys)(props).forEach(name => { | ||
let func = props[name]; | ||
if (typeof func !== 'function') func = prop(func); | ||
func({ constructor }, name); | ||
}); | ||
} | ||
(0, _index.keys)(props).forEach(name => { | ||
let func = props[name]; | ||
if (typeof func !== 'function') func = prop(func); | ||
func({ constructor }, name); | ||
}); | ||
} | ||
@@ -44,11 +43,11 @@ | ||
// classes or share the instance anywhere where it's not intended to be shared explicitly in userland code. | ||
if (!constructor.hasOwnProperty('_props')) { | ||
constructor._props = {}; | ||
if (!constructor.hasOwnProperty('_propsNormalised')) { | ||
constructor._propsNormalised = {}; | ||
} | ||
// Cache the value so we can reference when syncing the attribute to the property. | ||
constructor._props[name] = normalised; | ||
constructor._propsNormalised[name] = normalised; | ||
if (normalised.attribute.source) { | ||
constructor.observedAttributes = normalised.attribute.source; | ||
constructor._observedAttributes.push(normalised.attribute.source); | ||
} | ||
@@ -77,3 +76,5 @@ | ||
const withUpdate = exports.withUpdate = (Base = HTMLElement) => { | ||
return class extends Base { | ||
var _class, _temp2; | ||
return _temp2 = _class = class extends Base { | ||
constructor(...args) { | ||
@@ -90,19 +91,11 @@ var _temp; | ||
defineProps(this); | ||
return this._observedAttributes || []; | ||
return this._observedAttributes; | ||
} | ||
static set observedAttributes(attrs) { | ||
this._observedAttributes = (this.observedAttributes || []).concat(attrs); | ||
} | ||
static get props() { | ||
return this._props || {}; | ||
return this._props; | ||
} | ||
static set props(props) { | ||
(0, _index.keys)(props).forEach(name => { | ||
let func = props[name]; | ||
if (typeof func !== 'function') func = prop(func); | ||
func({ constructor: this }, name); | ||
}); | ||
this._props = props; | ||
} | ||
@@ -169,3 +162,3 @@ | ||
} | ||
}; | ||
}, _class._observedAttributes = [], _temp2; | ||
}; | ||
@@ -172,0 +165,0 @@ |
@@ -26,3 +26,3 @@ { | ||
"types": "src/index.d.ts", | ||
"version": "5.1.0" | ||
"version": "5.1.1" | ||
} |
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
60441
1475