From 36467fab10028eabc474e1d6835d2aa5be13e56f Mon Sep 17 00:00:00 2001 From: Kevin Schaaf Date: Fri, 22 Jul 2016 11:40:14 -0700 Subject: [PATCH] Use _configValue to avoid setting readOnly. Add tests. --- src/standard/configure.html | 6 ++-- test/unit/configure-elements.html | 50 +++++++++++++++++++++++++++++++ test/unit/configure.html | 19 ++++++++++++ 3 files changed, 72 insertions(+), 3 deletions(-) diff --git a/src/standard/configure.html b/src/standard/configure.html index 11c3a21e1e..2cb400a9b1 100644 --- a/src/standard/configure.html +++ b/src/standard/configure.html @@ -90,10 +90,10 @@ // e.g. hand template content stored in notes to children as part of // configure flow so templates have their content at ready time this._configureAnnotationReferences(); + // configure instance properties that may have been bound prior to upgrade + this._configureInstanceProperties(); // 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 @@ -122,7 +122,7 @@ // to not b0rk accessors on the prototype. // Perf testing has shown `hasOwnProperty` to be ok here. if (!usePolyfillProto && this.hasOwnProperty(i)) { - config[i] = this[i]; + this._configValue(i, this[i]); delete this[i]; } } diff --git a/test/unit/configure-elements.html b/test/unit/configure-elements.html index be40fcd34f..c093613afb 100644 --- a/test/unit/configure-elements.html +++ b/test/unit/configure-elements.html @@ -234,3 +234,53 @@ }); + + + + + + + diff --git a/test/unit/configure.html b/test/unit/configure.html index c55abb9e9e..985b6a70ad 100644 --- a/test/unit/configure.html +++ b/test/unit/configure.html @@ -186,6 +186,25 @@ assert.equal(x.b, 2); document.body.removeChild(x); }); + + test('lazy upgrade binding use cases', function() { + // don't test if __proto__ is polyfilled (IE10); cannot be fixed in this case. + if (Polymer.Settings.usePolyfillProto) { + return; + } + var el = document.createElement('x-config-lazy-host'); + document.body.appendChild(el); + Polymer(window.XConfigLazy); + assert.equal(el.$.lazy.noEffectProp, 1); + assert.equal(el.$.lazy.defaultUsesNoEffectProp, 2); + assert.equal(el.$.lazy.prop, 'foo'); + assert.isTrue(el.$.lazy.propChanged.calledOnce); + assert.equal(el.$.lazy.readOnlyProp, 'readOnly'); + assert.equal(el.$.lazy.hadAttrProp, 'foo'); + assert.isTrue(el.$.lazy.hadAttrPropChanged.calledOnce); + document.body.removeChild(el); + }); + });