Reputation:
I have a structure:
<div>
#shadow-root
<span>
How do I reference the div
from the span
?
span.parentNode
is the #shadow-root
, and .parentNode
from that is null
Upvotes: 5
Views: 2640
Reputation: 49150
First find shadowRoot host from the element el.getRootNode().host
and then use closest()
el.getRootNode().host.closest('div.my_div')
Upvotes: 0
Reputation: 24109
You can use shadowRoot.host
to give you the <div>
. Likewise, div.shadowRoot
would get you the div's shadow root.
Upvotes: 6