Skip to content

Commit ecd9b09

Browse files
committed
Fix for getters/setters for property become inaccessible when property set on element before it is ready
Test added
1 parent 9968266 commit ecd9b09

3 files changed

Lines changed: 37 additions & 3 deletions

File tree

‎src/standard/configure.html‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,10 @@
114114
_configureProperties: function(properties, config) {
115115
for (var i in properties) {
116116
var c = properties[i];
117-
// don't accept undefined values
118-
if (c.value !== undefined) {
117+
if (this[i] !== undefined) {
118+
config[i] = this[i];
119+
delete this[i];
120+
} else if (c.value !== undefined) {
119121
var value = c.value;
120122
if (typeof value == 'function') {
121123
// pass existing config values (this._config) to value function

‎test/unit/configure-elements.html‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,4 +164,28 @@
164164

165165
});
166166
</script>
167-
</dom-module>
167+
</dom-module>
168+
169+
<script>
170+
Polymer({
171+
is: 'x-configure-internal',
172+
properties: {
173+
shouldChange : {
174+
observer: 'shouldChangeCallback',
175+
type: String
176+
}
177+
},
178+
shouldChangeCallback: function() {
179+
this.innerHTML = this.shouldChange;
180+
}
181+
});
182+
</script>
183+
<script>
184+
Polymer({
185+
is: 'x-configure-external',
186+
ready: function() {
187+
var e = this.querySelector('x-configure-internal');
188+
e.shouldChange = 'It works';
189+
}
190+
});
191+
</script>

‎test/unit/configure.html‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626

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

29+
<x-configure-external>
30+
<x-configure-internal></x-configure-internal>
31+
</x-configure-external>
32+
2933
<script>
3034

3135
function testValueAndChangeHandler(e, value) {
@@ -87,6 +91,10 @@
8791
assert.equal(e.$.child.attr, undefined);
8892
});
8993

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

92100
</script>

0 commit comments

Comments
 (0)