import DOM from '@mojojs/dom';
const html = new DOM('<html><body><p>Test 1</p><p>Test 2</p></body></html>');
const div = new DOM('<div>Hello World!</div>', {fragment: true});
html.at('p').replace(div);
It would be nice if the case above was optimized, so that replace didn't have to stringify and re-parse the div snippet. Since our node tree is made up of classes, a simple deep clone on it won't work, but we could add clone methods to all the node classes, so that const clone = div.currentNode.clone() would simply give us a proper deep cloned version with classes in tact. Then all the modification methods of the DOM object could rely on that.
It would be nice if the case above was optimized, so that
replace
didn't have to stringify and re-parse thediv
snippet. Since our node tree is made up of classes, a simple deep clone on it won't work, but we could addclone
methods to all the node classes, so thatconst clone = div.currentNode.clone()
would simply give us a proper deep cloned version with classes in tact. Then all the modification methods of theDOM
object could rely on that.