I want to query elements inside of my shadow dom slot element. Do I need to loop through what assignedNodes() returns and parse them myself?
Asked
Active
Viewed 214 times
-2
-
1yes thats what you need to do. – Helping hand Aug 05 '18 at 15:03
-
you can also query the light DOM directly – Supersharp Aug 06 '18 at 16:42
1 Answers
0
I solved this issue by having the child element loop through the element's parent nodes until it finds the tag I am looking for.
var el = this; //the child element
while (el.parentNode) {
el = el.parentNode;
if (el.tagName == 'TAG-NAME'){ // The parent's tag name you're searching for.
this.parentElement = el;
break;
}
}
I also tried this with this.closest(), but Firefox had issues with that jumping between shadow dom.

Aaron
- 93
- 7