Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shady tests throw due to CE polyfill forced on in an unsafe way #5267

Closed
4 of 6 tasks
kevinpschaaf opened this issue Jun 22, 2018 · 0 comments
Closed
4 of 6 tasks

Shady tests throw due to CE polyfill forced on in an unsafe way #5267

kevinpschaaf opened this issue Jun 22, 2018 · 0 comments

Comments

@kevinpschaaf
Copy link
Member

kevinpschaaf commented Jun 22, 2018

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant