mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
Ensure DisableUpgradeMixin extends PropertiesMixin
This commit is contained in:
@@ -1377,27 +1377,26 @@ Polymer_ArraySelectorMixin.prototype.select = function(item){};
|
||||
Polymer_ArraySelectorMixin.prototype.selectIndex = function(idx){};
|
||||
/**
|
||||
* @interface
|
||||
* @extends {Polymer_PropertiesChanged}
|
||||
*/
|
||||
function Polymer_DisableUpgradeMixin(){}
|
||||
/**
|
||||
* @param {*} name
|
||||
* @param {*} old
|
||||
* @param {*} value
|
||||
* @override
|
||||
*/
|
||||
Polymer_DisableUpgradeMixin.prototype.attributeChangedCallback = function(name, old, value){};
|
||||
/**
|
||||
* @return {undefined}
|
||||
* @override
|
||||
*/
|
||||
Polymer_DisableUpgradeMixin.prototype._initializeProperties = function(){};
|
||||
/**
|
||||
* @return {undefined}
|
||||
* @override
|
||||
*/
|
||||
Polymer_DisableUpgradeMixin.prototype.connectedCallback = function(){};
|
||||
/**
|
||||
* @return {undefined}
|
||||
* @override
|
||||
*/
|
||||
Polymer_DisableUpgradeMixin.prototype._enableProperties = function(){};
|
||||
/**
|
||||
* @return {undefined}
|
||||
* @override
|
||||
*/
|
||||
Polymer_DisableUpgradeMixin.prototype.disconnectedCallback = function(){};
|
||||
@@ -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;
|
||||
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
|
||||
20
types/lib/mixins/disable-upgrade-mixin.d.ts
vendored
20
types/lib/mixins/disable-upgrade-mixin.d.ts
vendored
@@ -31,7 +31,7 @@ declare namespace Polymer {
|
||||
*
|
||||
* MyClass = Polymer.DisableUpgradeMixin(class extends BaseClass {...});
|
||||
*/
|
||||
function DisableUpgradeMixin<T extends new (...args: any[]) => {}>(base: T): T & DisableUpgradeMixinConstructor;
|
||||
function DisableUpgradeMixin<T extends new (...args: any[]) => {}>(base: T): T & DisableUpgradeMixinConstructor & Polymer.PropertiesChangedConstructor;
|
||||
|
||||
interface DisableUpgradeMixinConstructor {
|
||||
new(...args: any[]): DisableUpgradeMixin;
|
||||
@@ -39,27 +39,9 @@ declare namespace Polymer {
|
||||
|
||||
interface DisableUpgradeMixin {
|
||||
attributeChangedCallback(name: any, old: any, value: any): void;
|
||||
|
||||
/**
|
||||
* NOTE: cannot gate on attribute because this is called before
|
||||
* attributes are delivered. Therefore, we stub this out and
|
||||
* call `super._initializeProperties()` manually.
|
||||
*/
|
||||
_initializeProperties(): void;
|
||||
|
||||
/**
|
||||
* prevent user code in connected from running
|
||||
*/
|
||||
connectedCallback(): void;
|
||||
|
||||
/**
|
||||
* prevent element from turning on properties
|
||||
*/
|
||||
_enableProperties(): void;
|
||||
|
||||
/**
|
||||
* only go if "enabled"
|
||||
*/
|
||||
disconnectedCallback(): void;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user