Ensure DisableUpgradeMixin extends PropertiesMixin

This commit is contained in:
Daniel Freedman
2018-02-21 12:45:18 -08:00
parent b8c66ded58
commit 7e74e363ff
3 changed files with 31 additions and 30 deletions

View File

@@ -35,16 +35,30 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
*
* @mixinFunction
* @polymer
* @appliesMixin Polymer.PropertiesChanged
* @memberof Polymer
*/
Polymer.DisableUpgradeMixin = (base) => {
Polymer.DisableUpgradeMixin = Polymer.dedupingMixin((base) => {
return class DisableUpgradeClass extends base {
/**
* @constructor
* @extends {base}
* @implements {Polymer_PropertiesMixin}
*/
const superClass = Polymer.PropertiesMixin(base);
/**
* @polymer
* @mixinClass
* @implements {Polymer_DisableUpgradeMixin}
*/
class DisableUpgradeClass extends superClass {
/** @override */
static get observedAttributes() {
return super.observedAttributes.concat(DISABLED_ATTR);
}
/** @override */
attributeChangedCallback(name, old, value) {
if (name == DISABLED_ATTR) {
if (!this.__dataEnabled && value == null && this.isConnected) {
@@ -60,9 +74,11 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
attributes are delivered. Therefore, we stub this out and
call `super._initializeProperties()` manually.
*/
/** @override */
_initializeProperties() {}
// prevent user code in connected from running
/** @override */
connectedCallback() {
if (this.__dataEnabled || !this.hasAttribute(DISABLED_ATTR)) {
super.connectedCallback();
@@ -70,6 +86,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
}
// prevent element from turning on properties
/** @override */
_enableProperties() {
if (!this.hasAttribute(DISABLED_ATTR)) {
if (!this.__dataEnabled) {
@@ -80,15 +97,18 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
}
// only go if "enabled"
/** @override */
disconnectedCallback() {
if (this.__dataEnabled) {
super.disconnectedCallback();
}
}
};
}
};
return DisableUpgradeClass;
});
})();