mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
Merge branch 'fix-for-2348' of https://github.com/nazar-pc/polymer into nazar-pc-fix-for-2348
# Conflicts: # test/unit/configure.html + use hasOwnProperty check; benchmarking indicates perf is ok. + refine test.
This commit is contained in:
commit
d99e6939d6
@ -114,8 +114,14 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||||||
_configureProperties: function(properties, config) {
|
_configureProperties: function(properties, config) {
|
||||||
for (var i in properties) {
|
for (var i in properties) {
|
||||||
var c = properties[i];
|
var c = properties[i];
|
||||||
// don't accept undefined values
|
// Allow properties set before upgrade on the instance
|
||||||
if (c.value !== undefined) {
|
// to override default values. This allows late upgrade + an early set
|
||||||
|
// to not b0rk accessors on the prototype.
|
||||||
|
// Perf testing has shown `hasOwnProperty` to be ok here.
|
||||||
|
if (this.hasOwnProperty(i)) {
|
||||||
|
config[i] = this[i];
|
||||||
|
delete this[i];
|
||||||
|
} else if (c.value !== undefined) {
|
||||||
var value = c.value;
|
var value = c.value;
|
||||||
if (typeof value == 'function') {
|
if (typeof value == 'function') {
|
||||||
// pass existing config values (this._config) to value function
|
// pass existing config values (this._config) to value function
|
||||||
|
@ -103,6 +103,32 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||||||
assert.equal(e.$.child.attrNumberChanged.getCall(0).args[0], 42);
|
assert.equal(e.$.child.attrNumberChanged.getCall(0).args[0], 42);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('pre-register property assignment does not break getters and setters', function() {
|
||||||
|
var x = document.createElement('x-late-register');
|
||||||
|
document.body.appendChild(x);
|
||||||
|
// set property
|
||||||
|
x.shouldChange = '1';
|
||||||
|
// now register element
|
||||||
|
Polymer({
|
||||||
|
is: 'x-late-register',
|
||||||
|
properties: {
|
||||||
|
shouldChange : {
|
||||||
|
observer: 'shouldChangeCallback',
|
||||||
|
type: String
|
||||||
|
}
|
||||||
|
},
|
||||||
|
shouldChangeCallback: function() {
|
||||||
|
this.textContent = this.shouldChange;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
CustomElements.takeRecords();
|
||||||
|
assert.equal(x.shouldChange, '1');
|
||||||
|
assert.equal(x.shouldChange, x.textContent);
|
||||||
|
x.shouldChange = '2';
|
||||||
|
assert.equal(x.shouldChange, '2');
|
||||||
|
assert.equal(x.shouldChange, x.textContent);
|
||||||
|
document.body.removeChild(x);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user