diff --git a/lib/legacy/legacy-element-mixin.html b/lib/legacy/legacy-element-mixin.html index 6272b1cecf..6de979f229 100644 --- a/lib/legacy/legacy-element-mixin.html +++ b/lib/legacy/legacy-element-mixin.html @@ -57,6 +57,7 @@ constructor() { super(); + this.root = this; this.created(); } diff --git a/lib/mixins/element-mixin.html b/lib/mixins/element-mixin.html index 18d63eaac5..309f680f5d 100644 --- a/lib/mixins/element-mixin.html +++ b/lib/mixins/element-mixin.html @@ -119,6 +119,8 @@ let caseMap = Polymer.CaseMap; + const DISABLED = 'disable-upgrade'; + /** * Returns the `properties` object specifically on `klass`. Use for: * (1) super chain mixes togther to make `propertiesForClass` which is @@ -437,7 +439,7 @@ */ static get observedAttributes() { if (!this.hasOwnProperty(goog.reflect.objectProperty('__observedAttributes', this))) { - let list = []; + let list = [DISABLED]; let properties = propertiesForClass(this); for (let prop in properties) { list.push(Polymer.CaseMap.camelToDashCase(prop)); @@ -533,17 +535,6 @@ return this._importPath; } - constructor() { - super(); - Polymer.telemetry.instanceCount++; - // Stamp template - if (this._template) { - this.root = this._stampTemplate(this._template); - } else { - this.root = this; - } - } - /** * Overrides the default `Polymer.PropertyAccessors` to ensure class * metaprogramming related to property accessors and effects has @@ -555,6 +546,8 @@ * @override */ _initializeProperties() { + Polymer.telemetry.instanceCount++; + this.__upgradeFlush = null; this.constructor.finalize(); const importPath = this.constructor.importPath; // note: finalize template when we have access to `localName` to @@ -615,6 +608,18 @@ */ disconnectedCallback() {} + /** + * Stamps the element template. + * + * @override + */ + ready() { + if (this._template) { + this.root = this._stampTemplate(this._template); + } + super.ready(); + } + /** * Implements `PropertyEffects`'s `_readyClients` call. Attaches * element dom by calling `_attachDom` with the dom stamped from the @@ -673,7 +678,18 @@ * @override */ attributeChangedCallback(name, old, value) { - if (old !== value) { + // process `disable-upgrade` specially + if (name === DISABLED) { + const disabled = value !== null; + if (this.__upgradeFlush && !disabled) { + this._flushProperties = this.__upgradeFlush; + this.__upgradeFlush = null; + this._flushProperties(); + } else if (disabled) { + this.__upgradeFlush = this._flushProperties; + this._flushProperties = function() {}; + } + } else if (old !== value) { let property = caseMap.dashToCamelCase(name); let type = propertiesForClass(this.constructor)[property].type; if (!this._hasReadOnlyEffect(property)) { diff --git a/lib/mixins/template-stamp.html b/lib/mixins/template-stamp.html index ac10e38fdd..d6b21fc069 100644 --- a/lib/mixins/template-stamp.html +++ b/lib/mixins/template-stamp.html @@ -454,8 +454,8 @@ return class TemplateStamp extends superClass { - constructor() { - super(); + _initializeProperties() { + super._initializeProperties(); this.$ = null; this.__templateNodes = null; this.__templateNotes = null; diff --git a/lib/utils/render-status.html b/lib/utils/render-status.html index 1713b57d57..8ab664ed5b 100644 --- a/lib/utils/render-status.html +++ b/lib/utils/render-status.html @@ -32,7 +32,10 @@ } function flushQueue(queue) { - while (queue.length) { + const max = queue.length; + let i=0; + while (queue.length && i < max) { + i++; const q = queue.shift(); const context = q[0]; const callback = q[1]; diff --git a/test/runner.html b/test/runner.html index 6ac8473e86..86c18d4d2c 100644 --- a/test/runner.html +++ b/test/runner.html @@ -68,7 +68,8 @@ 'unit/logging.html', 'unit/mixin-utils.html', 'unit/mixin-behaviors.html', - 'unit/render-status.html' + 'unit/render-status.html', + 'unit/disable-upgrade.html' ]; // http://eddmann.com/posts/cartesian-product-in-javascript/ diff --git a/test/smoke/disable-upgrade.html b/test/smoke/disable-upgrade.html new file mode 100644 index 0000000000..0897b46d03 --- /dev/null +++ b/test/smoke/disable-upgrade.html @@ -0,0 +1,98 @@ + + + +
+ + + + + +