Skip to content

Commit 4cfb245

Browse files
author
Steven Orvell
committed
Restrict early property set to properties that have accessors. This allows users to set properties in created which are listed in properties but which have no accessor.
1 parent 667a9b6 commit 4cfb245

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/standard/configure.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@
120120
// to override default values. This allows late upgrade + an early set
121121
// to not b0rk accessors on the prototype.
122122
// Perf testing has shown `hasOwnProperty` to be ok here.
123-
if (!usePolyfillProto && this.hasOwnProperty(i)) {
123+
if (!usePolyfillProto && this.hasOwnProperty(i) &&
124+
this._propertyEffects && this._propertyEffects[i]) {
124125
config[i] = this[i];
125126
delete this[i];
126127
} else if (c.value !== undefined) {

test/unit/configure.html

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,35 @@
133133
assert.equal(x.shouldChange, x.textContent);
134134
document.body.removeChild(x);
135135
});
136+
137+
test('setting properties in created works with configuration', function() {
138+
// don't test if __proto__ is polyfilled (IE10); cannot be fixed in this case.
139+
if (Polymer.Settings.usePolyfillProto) {
140+
return;
141+
}
142+
var x = document.createElement('x-late-register2');
143+
document.body.appendChild(x);
144+
// now register element
145+
Polymer({
146+
is: 'x-late-register2',
147+
properties: {
148+
a: {
149+
type: Number
150+
},
151+
b: {
152+
value: function() {
153+
return this.a * 2;
154+
}
155+
}
156+
},
157+
created: function() {
158+
this.a = 1;
159+
}
160+
});
161+
CustomElements.takeRecords();
162+
assert.equal(x.b, 2);
163+
document.body.removeChild(x);
164+
});
136165
});
137166

138167
</script>

0 commit comments

Comments
 (0)