As the title says, how do I get all elements including open shadowRoot
elements and their children, which might also contain open shadowRoot elements?
I've found a few similar questions on SO, but they all return (inner|outer)HTML, which is similar but also very different logic. I want to return an object or array with the shadowRoot elements included.
I don't mind switching from getElementsByTagName("*")
to querySelectorAll("*")
if it makes things easier, but I don't think it will.
Edit
I don't think it's possible to accomplish what I want here, e.g. return an object/array of all elements on the page including nested shadowRoot
elements. Again, my end goal is to getComputedStyle()
on every element on the page, including shadowRoot nodes.
The only thing I can think of to accomplish this would be to use a function similar to this on SO or this on SO to get all the HTML, add it to the page somewhere hidden, parse it, then optionally remove it from the page.
Any suggestions or ideas are appreciated.