From 4c023740a33ce3100ccf59c6d98e8d1be79488f5 Mon Sep 17 00:00:00 2001 From: Kevin Schaaf Date: Mon, 17 Apr 2017 17:09:34 -0700 Subject: [PATCH] Guard against overwriting bound values with hasOwnProperty. Fixes #4540 --- lib/mixins/element-mixin.html | 7 +++++-- test/unit/configure.html | 7 ++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/mixins/element-mixin.html b/lib/mixins/element-mixin.html index a8b6a0d8c2..fa5122cea6 100644 --- a/lib/mixins/element-mixin.html +++ b/lib/mixins/element-mixin.html @@ -597,14 +597,17 @@ } for (let p in p$) { let info = p$[p]; - if (!this._isPropertyPending(p)) { + // Don't set default value if there is already an own property, which + // happens when a `properties` property with default but no effects had + // a property set (e.g. bound) by its host before upgrade + if (!this.hasOwnProperty(p)) { let value = typeof info.value == 'function' ? info.value.call(this) : info.value; // Set via `_setProperty` if there is an accessor, to enable // initializing readOnly property defaults if (this._hasAccessor(p)) { - this._setProperty(p, value) + this._setPendingProperty(p, value, true); } else { this[p] = value; } diff --git a/test/unit/configure.html b/test/unit/configure.html index 02d7921283..21ce6d5269 100644 --- a/test/unit/configure.html +++ b/test/unit/configure.html @@ -270,6 +270,10 @@ defaultUsesNoEffectProp: { type: Number }, + boundNoEffectProp: { + type: Number, + value: 5 + }, prop: { value: 'lazy', observer: 'propChanged' @@ -294,7 +298,7 @@