Fix for getters/setters for property become inaccessible when property set on element before it is ready

Test added
This commit is contained in:
Nazar Mokrynskyi 2015-08-23 00:23:31 +02:00
parent 9968266e74
commit ecd9b0902d
3 changed files with 37 additions and 3 deletions

View File

@ -114,8 +114,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
_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

View File

@ -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>

View File

@ -26,6 +26,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
<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) {
@ -87,6 +91,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
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>