I'm using web components with shadow DOM on a project and I would like to copy the innerHTML of the page as rendered.
I think I need to write a function loops over each DOM node and gets either the shadow DOM children if available or else the light DOM children.
node.shadowRoot ? node.shadowRoot.children : node.children
I've been having trouble getting it right, and I'm surprised I can't find anything on Google.