mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #3417 from Polymer/nazar-pc-fix-for-2348
Nazar-pc fix for #2348
This commit is contained in:
commit
9bdfacad72
@ -38,6 +38,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||||||
var useNativeCustomElements = (!window.CustomElements ||
|
var useNativeCustomElements = (!window.CustomElements ||
|
||||||
window.CustomElements.useNative);
|
window.CustomElements.useNative);
|
||||||
|
|
||||||
|
var usePolyfillProto = !useNativeCustomElements && !Object.__proto__;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
wantShadow: wantShadow,
|
wantShadow: wantShadow,
|
||||||
hasShadow: hasShadow,
|
hasShadow: hasShadow,
|
||||||
@ -45,7 +47,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||||||
useShadow: useShadow,
|
useShadow: useShadow,
|
||||||
useNativeShadow: useShadow && nativeShadow,
|
useNativeShadow: useShadow && nativeShadow,
|
||||||
useNativeImports: useNativeImports,
|
useNativeImports: useNativeImports,
|
||||||
useNativeCustomElements: useNativeCustomElements
|
useNativeCustomElements: useNativeCustomElements,
|
||||||
|
usePolyfillProto: usePolyfillProto
|
||||||
};
|
};
|
||||||
})()
|
})()
|
||||||
};
|
};
|
||||||
|
@ -9,7 +9,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
(function() {
|
||||||
/*
|
/*
|
||||||
Process inputs efficiently via a configure lifecycle callback.
|
Process inputs efficiently via a configure lifecycle callback.
|
||||||
Configure is called top-down, host before local dom. Users should
|
Configure is called top-down, host before local dom. Users should
|
||||||
@ -41,6 +41,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||||||
directly (on-foo-changed).
|
directly (on-foo-changed).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var usePolyfillProto = Polymer.Settings.usePolyfillProto;
|
||||||
|
|
||||||
Polymer.Base._addFeature({
|
Polymer.Base._addFeature({
|
||||||
|
|
||||||
// storage for configuration
|
// storage for configuration
|
||||||
@ -114,8 +116,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 (!usePolyfillProto && 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
|
||||||
@ -217,4 +225,5 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
@ -103,6 +103,36 @@ 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() {
|
||||||
|
// don't test if __proto__ is polyfilled (IE10); cannot be fixed in this case.
|
||||||
|
if (Polymer.Settings.usePolyfillProto) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
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