w3c / DOM-Parsing

DOM Parsing and Serialization
https://w3c.github.io/DOM-Parsing/
Other
27 stars 14 forks source link

Shadow DOM innerHTML #73

Closed GioValentin closed 2 years ago

GioValentin commented 2 years ago

There needs to be a way to read the contents of a shadow DOM regardless if it's closed or open when we're not the creator. The function getInnerHTML({includeShadowRoots: true}) works if the shadow root use the template syntax but if a shadow root is generated using a generic implementation like my example below then you can't get the contents of the html of the shadow root.

An example,

var _div = document.createElement('div'); var root = _div.attachShadow({mode: 'open'}); // or closed var helloWorld = document.createElement('div'); helloWorld.innerHTML = '

Hello World

';

root.appendChild(helloWorld);

I would like to be able to call the element and generate a string by doing element.shadowRoot.innerHTML. This works when we are the creator but it does not work when we're not.

sideshowbarker commented 2 years ago

Please re-raise this at https://github.com/whatwg/html/issues/new