-
Notifications
You must be signed in to change notification settings - Fork 165
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
[scoped-custom-element-registry] proof of concept to fix stand-in element issues #568
Comments
@sorvell small sugestion what about making |
I think this approach is looking viable. The POC version now passes the tests at https://github.com/open-wc/open-wc/blob/master/packages/scoped-elements. The biggest known issues are:
|
Would this affect all custom elements on a page or only those that opt in to scoped registries? Patching all custom elements is potentially problematic as that can have unintended consequences outside of Lit. |
Only scoped elements to be patched. And, since this is intended as a polyfill, the goal is to patch in a way that does not rely on any library (e.g. Lit). |
if you would rely it on lit would that make things more easy or the end result be the same ? |
Since the spec is still likely in flux and the first implementation is in progress, work has started on making this into a ponyfill. There are some pros and cons to this, captured below: Ponyfill v. Polyfill
ApproachesOverview
Form Associated
Attributes
Late Define (uncommon!)
Interaction with global registry
Performance: registry creation
Performance: creation
Performance: upgrades (uncommon!)
AlternativesElements can applly manual scoping using only the global registry by ensuring all elements are registered with unique names. This would work as follows:
|
Approach was abandoned due to complexity related mostly to the need to do manual upgrades for late definitions. |
Description
prototype new polyfill
This is an alternate way to implement the custom elements registry polyfill. Instead of polyfilling
CustomElementsRegistry
completely and using a stand-in proxy element that delegates to the proper scope, real scopes are created via theCustomElementsRegistry
available in an<iframe>
, with one<iframe>
per registry. This avoids the need to have a stand-in element proxy and the associated issues.Motivation
Address issues that result from the stand-in element approach, e.g.
Caveats
contentWindow
and associated globals; this may have issues with some CSP settings (needs research).connectedCallback
) being called in the correct scope. This is worked around currently, but a better fix should be researched.The text was updated successfully, but these errors were encountered: