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

Cross-realm well-known symbols #998

Closed
anilanar opened this issue Oct 21, 2021 · 1 comment
Closed

Cross-realm well-known symbols #998

anilanar opened this issue Oct 21, 2021 · 1 comment

Comments

@anilanar
Copy link

anilanar commented Oct 21, 2021

WellKnownSymbolsStore is not shared across realms, but Symbol.for is shared:

https://jakearchibald.com/2017/arrays-symbols-realms/

Reproduction:

  1. Load Symbol.observable polyfill in a modern/recent browser.
  2. Create same domain iframe and load another copy of Symbol.observable polyfill in the iframe.
  3. Compare Symbol.observable against Symbol.observable from the iframe, they won't be equal.

On the other hand, window.Symbol.for('observable') === iframe.window.Symbol.for('observable') so Symbol.for works across realms.

@zloirock
Copy link
Owner

zloirock commented Oct 21, 2021

Thanks for the issue. I thought about it. But someone could use Symbol.for('observable') for anything else and it will unexpectedly make objects with this property observable. However, sure, it could be solved by using something like prefixes. Also, it will not work with polyfilled Symbol - the proper cross-realm Symbol.for behavior can't be polyfilled, so we could forget about, for example, IE11 - that was the main reason why it's still not added.

@zloirock zloirock changed the title Don't use WellKnownSymbolsStore for Symbol.observable if when Symbol.for is available Cross-realm well-known symbols Oct 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants