Skip to content

Commit

Permalink
Fix for getters/setters for property become inaccessible when propert…
Browse files Browse the repository at this point in the history
…y set on element before it is ready

Test added
  • Loading branch information
nazar-pc committed Feb 5, 2016
1 parent 9968266 commit ecd9b09
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/standard/configure.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@
_configureProperties: function(properties, config) {
for (var i in properties) {
var c = properties[i];
// don't accept undefined values
if (c.value !== undefined) {
if (this[i] !== undefined) {
config[i] = this[i];
delete this[i];
} else if (c.value !== undefined) {
var value = c.value;
if (typeof value == 'function') {
// pass existing config values (this._config) to value function
Expand Down
26 changes: 25 additions & 1 deletion test/unit/configure-elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,28 @@

});
</script>
</dom-module>
</dom-module>

<script>
Polymer({
is: 'x-configure-internal',
properties: {
shouldChange : {
observer: 'shouldChangeCallback',
type: String
}
},
shouldChangeCallback: function() {
this.innerHTML = this.shouldChange;
}
});
</script>
<script>
Polymer({
is: 'x-configure-external',
ready: function() {
var e = this.querySelector('x-configure-internal');
e.shouldChange = 'It works';
}
});
</script>
8 changes: 8 additions & 0 deletions test/unit/configure.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@

<x-configure-host content="attr"></x-configure-host>

<x-configure-external>
<x-configure-internal></x-configure-internal>
</x-configure-external>

<script>

function testValueAndChangeHandler(e, value) {
Expand Down Expand Up @@ -87,6 +91,10 @@
assert.equal(e.$.child.attr, undefined);
});

test('direct property assignment overrides getters and setters', function() {
var e = document.querySelector('x-configure-internal');
assert.equal(e.innerHTML, 'It works');
});
});

</script>
Expand Down

0 comments on commit ecd9b09

Please sign in to comment.