Instead of iterating all children in a DOM Node, we can use a zero-argument replaceChildren()
call.
while (node.lastChild) {
node.lastChild.remove();
}
while (node.firstChild) {
node.firstChild.remove();
}
node.replaceChildren();
node.replaceChildren();
Not the same if iterating node.firstChildElement.remove()
or iterating node.lastChildElement.remove()
because the DOM structure can look like this:
<div>
Text Block 1
<input />
Text Block 2
</div>
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too