-
Notifications
You must be signed in to change notification settings - Fork 50.4k
Can bind events to ShadowRoots. #2617
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
Conversation
Otherwise they're still bound to the document and not the shadowroot.
|
Hmm, this is going to mean we walk up the whole DOM for every event listener we add, which is suboptimal (especially since we add listeners progressively as they get used). A couple things…
|
|
Hey, hi :) I can rework it and maybe add some tests 🔭 What would you suggest instead of iterating until we find if the node is indeed in a shadow dom or not? |
|
Also, what's wrong with recursion in this case? Is there any risk to reach the stack limit? 😭 |
Uses a while loop instead of recursivly calling `parentNode`. Reuses node.ownerDocument when shadowRoot isn't supported.
|
We probably won't hit the stack limit. My concern is that I'm not sure if engines would do tail call optimizations and eliminate the need for creating all the things functions need. There is definitely overhead in that unless engines are smart (I think most are but I'm not certain). |
|
I changed it to an iterative way. 👍 |
|
I realize that might sound crazy, but how about storing in the react element if it has is "shadow react" element? If the property is false, we bind to |
|
We want to do document wide delegation and use
However, this spec has been changing so we temporarily disabled it. |
I created a chrome extension with react. And when inserting in the DOM, the styles would collapse with the page.
The solution I found was the most elegant was to create a shadow root and render my react component inside it.
Problem is that the events were not bound properly because of shadow boundaries. Here are my modifications :)