-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
Bind event listeners to the shadow root if a component is being rendered into one #859
Bind event listeners to the shadow root if a component is being rendered into one #859
Conversation
* defined if it can actually run. | ||
*/ | ||
var owningDocument = (function() { | ||
if (typeof window != "undefined") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use ExecutionEnvironment.canUseDOM
?
@petehunt do have any further feedback on this change? |
Would love to see this land 👍 |
function putListener(id, registrationName, listener) { | ||
var container = ReactMount.findReactContainerForID(id); | ||
if (container) { | ||
var doc = container.nodeType === ELEMENT_NODE_TYPE ? | ||
container.ownerDocument : | ||
owningDocument(container) : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's Element.shadowRoot per spec http://www.w3.org/TR/shadow-dom/#api-partial-element-shadow-root, can it be used instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately no. The shadowRoot
property is the ShadowRoot that is being rendered inside of the element, not the one the element is inside of.
I'm not aware of any more efficient way to determine in which ShadowRoot (if any) a given element is. But I also haven't investigated deeply.
Now that shadow DOM is shipping in Chrome I think we should take this. @wereHamster have you run into any other issues with shadowdom + react? |
I ported my whole codebase to react only and am not using Polymer anymore. So I can't comment on any issues. |
@wereHamster I know you said you weren't using Polymer anymore, but if you have a simple example that should work but was broken, that would be helpful for somebody who might be interested in picking it up. In the meantime, I think I'll close this out since we dropped the ball (sorry!). If you're interested in picking it back up, just reopen! |
Related discussion is in #840.