mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
Fix for getters/setters for property become inaccessible when property set on element before it is ready
Test added
This commit is contained in:
parent
9968266e74
commit
ecd9b0902d
@ -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
|
||||
|
@ -165,3 +165,27 @@
|
||||
});
|
||||
</script>
|
||||
</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>
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user