Merge pull request #3447 from Polymer/config-noeffect

Make sure to configure properties on polymer elements that do not have property effects
This commit is contained in:
Daniel Freedman 2016-02-19 15:24:56 -08:00
commit d1ee1423cb
3 changed files with 33 additions and 3 deletions

View File

@ -149,14 +149,17 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var node = this._nodes[x.effect.index]; var node = this._nodes[x.effect.index];
var name = x.effect.propertyName; var name = x.effect.propertyName;
// seeding configuration only // seeding configuration only
if (node._propertyEffects && node._propertyEffects[name]) { var isAttr = (x.effect.kind == 'attribute');
var hasEffect = (node._propertyEffects &&
node._propertyEffects[name]);
if (node._configValue && (hasEffect || !isAttr)) {
var value = (p === x.effect.value) ? config[p] : var value = (p === x.effect.value) ? config[p] :
this._get(x.effect.value, config); this._get(x.effect.value, config);
if (x.effect.kind == 'attribute') { if (isAttr) {
// For attribute bindings, flow through the same ser/deser // For attribute bindings, flow through the same ser/deser
// process to ensure the value is the same as if it were // process to ensure the value is the same as if it were
// bound through the attribute // bound through the attribute
value = node.deserialize(node.serialize(value), value = node.deserialize(this.serialize(value),
node._propertyInfo[name].type); node._propertyInfo[name].type);
} }
node._configValue(name, value); node._configValue(name, value);

View File

@ -146,9 +146,28 @@
</script> </script>
</dom-module> </dom-module>
<dom-module id="x-configure-simple-child">
<script>
Polymer({
is: 'x-configure-simple-child',
properties: {
noeffect: String
},
ready: function() {
this.hasPropertyAtReadyTime = (this.noeffect !== undefined);
}
});
</script>
</dom-module>
<dom-module id="x-configure-host"> <dom-module id="x-configure-host">
<template> <template>
<x-configure-child id="child" content="{{content}}" object="{{object.goo}}" attr$="{{attrValue}}" attr-dash$="{{attrValue}}" attr-number$="{{attrNumber}}" attr-boolean$="{{attrBoolean}}"></x-configure-child> <x-configure-child id="child" content="{{content}}" object="{{object.goo}}" attr$="{{attrValue}}" attr-dash$="{{attrValue}}" attr-number$="{{attrNumber}}" attr-boolean$="{{attrBoolean}}"></x-configure-child>
<x-configure-simple-child id="simple" noeffect="{{simple}}"></x-configure-simple-child>
</template> </template>
<script> <script>
Polymer({ Polymer({
@ -185,6 +204,9 @@
}, },
attrBoolean: { attrBoolean: {
value: false value: false
},
simple: {
value: 'simple'
} }
} }

View File

@ -109,6 +109,11 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
assert.strictEqual(e.$.child.attrBooleanChanged.getCall(0).args[0], false); assert.strictEqual(e.$.child.attrBooleanChanged.getCall(0).args[0], false);
}); });
test('bindings to properties without effects configured', function() {
var e = document.createElement('x-configure-host');
assert.isTrue(e.$.simple.hasPropertyAtReadyTime, 'property value not configured and therefore not set at ready time');
});
test('pre-register property assignment does not break getters and setters', function() { test('pre-register property assignment does not break getters and setters', function() {
// don't test if __proto__ is polyfilled (IE10); cannot be fixed in this case. // don't test if __proto__ is polyfilled (IE10); cannot be fixed in this case.
if (Polymer.Settings.usePolyfillProto) { if (Polymer.Settings.usePolyfillProto) {