-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
Description
A handful of shady-related tests force the CE polyfill on like this:
if (!window.customElements) {
window.customElements = {};
}
customElements.forcePolyfill = true;This is unsafe since any code using windows.customElements as a shorthand for detecting support for custom elements will fail prior to loading the actual CE polyfill, since that object doesn't express the CE API. A recent change in shadydom polyfill causes these tests to throw upon loading the shadydom polyfill. Arguably that code could also do a more strict check that both window.customElements && window.customElements.define exist before patching it (which is what the CE polyfill does), but generally seems bad to have a fake object masquerading as a browser API, so choosing to fix it here.
The proper way to force the CE polyfill on is this pattern (the flag only needs to be set if CE exists; if it doesn't exist, the polyfill will be enabled anyway):
if (window.customElements) {
customElements.forcePolyfill = true;
}Browsers Affected
- Chrome
- Firefox
- Edge
- Safari 11
- Safari 10
- IE 11
Versions
- Polymer: v2.x, v3.x
- shadydom: v1.1.0