From f2938ec499ababba6e6397b6f036a5e3fa8a82b1 Mon Sep 17 00:00:00 2001 From: Kevin Schaaf Date: Tue, 12 Jul 2016 10:34:31 -0700 Subject: [PATCH] Ensure properties override attributes at upgrade time. Fixes #3779. --- src/lib/template/dom-bind.html | 9 +++++++-- src/standard/configure.html | 19 +++++++++++++------ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/lib/template/dom-bind.html b/src/lib/template/dom-bind.html index 58b051bc00..10dc8bf40c 100644 --- a/src/lib/template/dom-bind.html +++ b/src/lib/template/dom-bind.html @@ -71,9 +71,9 @@ Polymer.RenderStatus.whenReady(function() { if (document.readyState == 'loading') { document.addEventListener('DOMContentLoaded', function() { - self._markImportsReady(); + self._markImportsReady(); }); - } else { + } else { self._markImportsReady(); } }); @@ -123,6 +123,11 @@ } }, + _configureInstanceProperties: function() { + // We use the _prepConfigure code below to read instance values before + // creating instance accessors, rather than the standard method here + }, + _prepConfigure: function() { var config = {}; for (var prop in this._propertyEffects) { diff --git a/src/standard/configure.html b/src/standard/configure.html index 0d496e9de8..11c3a21e1e 100644 --- a/src/standard/configure.html +++ b/src/standard/configure.html @@ -92,6 +92,8 @@ this._configureAnnotationReferences(); // save copy of configuration that came from above this._aboveConfig = this.mixin({}, this._config); + // save instance properties that may have been bound prior to upgrade + this._configureInstanceProperties(this._aboveConfig); // get individual default values from property configs var config = {}; // mixed-in behaviors @@ -113,18 +115,23 @@ } }, - _configureProperties: function(properties, config) { - for (var i in properties) { - var c = properties[i]; + _configureInstanceProperties: function(config) { + for (var i in this._propertyEffects) { // Allow properties set before upgrade on the instance // to override default values. This allows late upgrade + an early set // to not b0rk accessors on the prototype. // Perf testing has shown `hasOwnProperty` to be ok here. - if (!usePolyfillProto && this.hasOwnProperty(i) && - this._propertyEffects && this._propertyEffects[i]) { + if (!usePolyfillProto && this.hasOwnProperty(i)) { config[i] = this[i]; delete this[i]; - } else if (c.value !== undefined) { + } + } + }, + + _configureProperties: function(properties, config) { + for (var i in properties) { + var c = properties[i]; + if (c.value !== undefined) { var value = c.value; if (typeof value == 'function') { // pass existing config values (this._config) to value function