Message from JavaScript discussions
November 2018
— Currently, I’m creating html
, head
, and body
elements by hand, insert the head and body markup and then I append the head
and body
elements to the html
element. This feels ... very odd to write out.
Wait a minute the shadow DOM was this thing in React or VueJS that renders, set HTML, only when smthing changes?
— You are maybe talking about Virtual DOM?
— Oh
— Yes
— Lol
— Yikes :D
— Shadow dom is not the iframe thing, right
— What effect you try to achive?
— If you think what I think you think, it is. It allows you to attach DOM fragments to it. The goal is to isolate the shadow DOM from the parent/host DOM. The main purpose is style isolation.
— My use case is rather complex. I’m rendering a full document inside another document. Currently, I manually inject the body contents into a certain element in the parent document’s body. Script, style and link tags are injected into the parent document’s head.
— It would be far preferable to just have the document be a shadow DOM inside the parent document. This would automatically load any scripts/styles, but also isolate styles to the shadow DOM.