Describe the bug
Since the 0.8.4 update, documents do not seem to realize that they've lost their (only) child when they get reparented.
To Reproduce
https://stackblitz.com/edit/js-xmldom-template-myg9ht?file=index.js
const doc = new DOMParser().parseFromString('<svg/>', 'image/svg+xml');
const oldRoot = doc.firstChild;
const newRoot = doc.createElement('svg');
newRoot.appendChild(oldRoot);
console.log('After first move, document has', doc.childNodes.length, 'children (should be 0)');
doc.appendChild(newRoot);
console.log('After second move, document has', doc.childNodes.length, 'children (should be 1)');
Expected behavior
newRoot.appendChild(oldRoot) should change the oldRoot's parent to be the newRoot, which should mean that the document loses its child. Running the above code in Chrome's console confirms this behavior. Instead I get:
xmldom 0.8.4 instead says that the document still has 1 child after the first move, so the second move fails according to the new one-child-per-document rule. (Error: Hierarchy request error: Only one element can be added and only after doctype)
xmldom 0.8.3 somehow says 1 child after both moves, which is why I didn't see this issue before, but it's still wrong (should be 0 after the first move).
Runtime & Version:
xmldom version: 0.8.4
runtime version: Node v18.7.0
other related software and version: WIndows 11
Describe the bug
Since the 0.8.4 update, documents do not seem to realize that they've lost their (only) child when they get reparented.
To Reproduce
https://stackblitz.com/edit/js-xmldom-template-myg9ht?file=index.js
Expected behavior
newRoot.appendChild(oldRoot)should change theoldRoot's parent to be thenewRoot, which should mean that the document loses its child. Running the above code in Chrome's console confirms this behavior. Instead I get:xmldom 0.8.4 instead says that the document still has 1 child after the first move, so the second move fails according to the new one-child-per-document rule. (
Error: Hierarchy request error: Only one element can be added and only after doctype)xmldom 0.8.3 somehow says 1 child after both moves, which is why I didn't see this issue before, but it's still wrong (should be 0 after the first move).
Runtime & Version:
xmldom version: 0.8.4
runtime version: Node v18.7.0
other related software and version: WIndows 11