-2

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?

Aaron
  • 93
  • 7

1 Answers1

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