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

Rendering component into a shadow root in React 15.x #6456

Closed
Wildhoney opened this issue Apr 8, 2016 · 4 comments
Closed

Rendering component into a shadow root in React 15.x #6456

Wildhoney opened this issue Apr 8, 2016 · 4 comments

Comments

@Wildhoney
Copy link
Contributor

In 0.14 it was quite easy to render a component into a shadow root — this was due to the nodeType check in ReactDOMComponent.

However you'll notice that in 15.0 that check has been completely removed and as such will always bind events to the #document element — the ownerDocument, rather than the #document-fragment.

As the events that cross the shadow boundary are retargeted to appear as though they're from the shadow host instead of the internals, React's event delegating fails to invoke the event function. In the case of 0.14 the event delegation on the #document-fragment correctly handled the event, as it was able to inspect the listenerBank before retargeting was performed — any further propagation of the event would have been unnecessary.

Now I realise React doesn't support Shadow DOM natively — however it seems as though we've taken a little step back, especially with Angular 2 and its Shadow DOM support on the horizon. I'm merely wondering as to the rationale behind the removal of the ownerDocument check, and whether we'd be happy to add it back in?

(For those people who dislike the CSS Module approach)

@jimfb
Copy link
Contributor

jimfb commented Apr 8, 2016

@Wildhoney Yes, we should probably add it back in. Without having looked into it deeply, my guess is that the breakage was just an oversight.

Would gladly accept a PR to fix this.

@Wildhoney
Copy link
Contributor Author

Agreed — I'll take a look. Thanks 👍

One quick question, however — otherwise I'll investigate myself — what is the easiest way to obtain the container (in this case the #document-fragment) from inst?

@jimfb
Copy link
Contributor

jimfb commented Apr 8, 2016

I'd look at nativeContainer and topLevelWrapper; the info might need to be added if it isn't already available. I think @spicyj wrote the nativeContainer code, so he might know. Otherwise, it'll require a bit of investigation.

@jimfb
Copy link
Contributor

jimfb commented Apr 14, 2016

Fixed in #6462

@jimfb jimfb closed this as completed Apr 14, 2016
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

3 participants