Skip to content

Commit

Permalink
Ensure properties override attributes at upgrade time. Fixes #3779.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed Jul 12, 2016
1 parent e579f58 commit f2938ec
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
9 changes: 7 additions & 2 deletions src/lib/template/dom-bind.html
Expand Up @@ -71,9 +71,9 @@
Polymer.RenderStatus.whenReady(function() {
if (document.readyState == 'loading') {
document.addEventListener('DOMContentLoaded', function() {
self._markImportsReady();
self._markImportsReady();
});
} else {
} else {
self._markImportsReady();
}
});
Expand Down Expand Up @@ -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) {
Expand Down
19 changes: 13 additions & 6 deletions src/standard/configure.html
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit f2938ec

Please sign in to comment.