Skip to content

Commit

Permalink
Merge pull request #3447 from Polymer/config-noeffect
Browse files Browse the repository at this point in the history
Make sure to configure properties on polymer elements that do not have property effects
  • Loading branch information
dfreedm committed Feb 19, 2016
2 parents 4136a8c + f93c3e5 commit d1ee142
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/standard/configure.html
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,17 @@
var node = this._nodes[x.effect.index];
var name = x.effect.propertyName;
// 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] :
this._get(x.effect.value, config);
if (x.effect.kind == 'attribute') {
if (isAttr) {
// For attribute bindings, flow through the same ser/deser
// process to ensure the value is the same as if it were
// bound through the attribute
value = node.deserialize(node.serialize(value),
value = node.deserialize(this.serialize(value),
node._propertyInfo[name].type);
}
node._configValue(name, value);
Expand Down
22 changes: 22 additions & 0 deletions test/unit/configure-elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,28 @@
</script>
</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">
<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-simple-child id="simple" noeffect="{{simple}}"></x-configure-simple-child>
</template>
<script>
Polymer({
Expand Down Expand Up @@ -185,6 +204,9 @@
},
attrBoolean: {
value: false
},
simple: {
value: 'simple'
}
}

Expand Down
5 changes: 5 additions & 0 deletions test/unit/configure.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@
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() {
// don't test if __proto__ is polyfilled (IE10); cannot be fixed in this case.
if (Polymer.Settings.usePolyfillProto) {
Expand Down

0 comments on commit d1ee142

Please sign in to comment.