How to serialize an HTML DOM including Shadow DOM?
<p>I want to serialize an entire HTML DOM including Shadow DOM trees into a string i.e. including both the shadow host and shadow root in a way that they can be reconstructed.</p>

<p>I can programatically access the Shadow DOM via .shadowRoot.innerHTML but calling .outerHTML on the entire DOM or using an XMLSerializer does not include the shadowRoot.</p>

<p>Is there a way to serialize the entire HTML document including Shadow DOM trees?</p>