I am involved in a project such that, let’s say we are given a DOM fragment, it actually represents what the CMS generated to render into a component.
So we can take this fragment, find the 3 children of it (child1, 2, 3), and then create another container, and add sub-containers, so that container1 contains the first child and container2. And then container2 contains child2 and child3.
And then finally, replace the children of the given fragment with container1.
I suppose it seems to work as long as I don’t create a cycle with a infinite loop, but even so, doing this appears to be a little bit flaky? By what rule does it say I can just go ahead and take elements out of a DOM and rearrange them and/or put them into new containers?