fix: more lightweight replaceChildren polyfill
This commit is contained in:
parent
472a27bc24
commit
ea25409acb
|
@ -17,13 +17,9 @@ function replaceChildren (parentNode, newChildren) {
|
|||
/* istanbul ignore else */
|
||||
if (hasReplaceChildren) {
|
||||
parentNode.replaceChildren(...newChildren)
|
||||
} else { // polyfill Element.prototype.replaceChildren
|
||||
while (parentNode.lastChild) {
|
||||
parentNode.removeChild(parentNode.lastChild)
|
||||
}
|
||||
for (const child of newChildren) {
|
||||
parentNode.appendChild(child)
|
||||
}
|
||||
} else { // minimal polyfill for Element.prototype.replaceChildren
|
||||
parentNode.innerHTML = ''
|
||||
parentNode.append(...newChildren)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue