How can I check if for an element inside a shadow DOM, the element itself is the shadow root ?
I tried if (elem===elem.getRootNode()) but this doesn't work, as one is an element and one is a Node.
What is the correct test ?
My case is that I have code a Chrome extension that climbs up the DOM tree from a given element doing elem = elem.parentElement until elem===document.documentElement.
I am now trying to extend the above test condition to work for elements inside shadow DOM. When climbing up from an element in a shadow DOM I want to end when reaching the root of the shadow DOM not the root of the entire page.
I only need a Chrome solution.