I'm trying to clone a shadow root, so that I may swap instances of <content></content>
with their corresponding distributed nodes.
My approach:
var shadowHost = document.createElement('div');
var shadowRoot = shadowHost.createShadowRoot();
var clonedShadowRoot = shadowRoot.cloneNode(true);
does not work, as "ShadowRoot nodes are not clonable.
"
The motivation for this is that I wish to retrieve the composed shadow tree, so that I may use the rendered HTML markup.
Edit: On second thought, this may not work due to the nature of the Shadow DOM, the reference to the distributed nodes is likely to be broken by the cloning process.
Composing the shadow tree is likely to be a native feature, but having searched through the w3c spec, I was unable to find such a method.
Is there such a native method? Or, failing that, would manual traversal (replicating the tree in the process), work?
from Cloning a ShadowRoot
No comments:
Post a Comment