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.
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.