implement m.domFor() and use it internally to move and remove nodes. Fix #2780

This commit is contained in:
Pierre-Yves 2022-06-09 13:50:27 +02:00 committed by Pierre-Yves Gérardy
parent 27fb1ea617
commit 3fd82e6359
8 changed files with 345 additions and 267 deletions

View file

@ -99,12 +99,15 @@ module.exports = function(options) {
}
}
function removeChild(child) {
if (child == null || typeof child !== 'object' || !("nodeType" in child)) {
throw new TypeError("Failed to execute removeChild, parameter is not of type 'Node'")
}
var index = this.childNodes.indexOf(child)
if (index > -1) {
this.childNodes.splice(index, 1)
child.parentNode = null
}
else throw new TypeError("Failed to execute 'removeChild'")
else throw new TypeError("Failed to execute 'removeChild', child not found in parent")
}
function insertBefore(child, reference) {
var ancestor = this