case 'tag':
if (c.name === 'script' || c.name === 'object' || c.name === 'iframe' || c.name === 'link') {
// TODO put placeholders instead
- remove.unshift(i)
+ remove.unshift(i) // add to beginning so they are removed last first
continue
}
// TODO create in correct namespace
}
}
}
- results = []
+ // these are in reverse order so we remove highest indexes first
for (i = 0; i < remove.length; i++) {
- // FIXME this deletes the wrong node when siblings are removed
index = remove[i]
- results.push(tree.splice(index, 1))
+ tree.splice(index, 1)
}
- return results
}
function traverse_tree (tree, cb) {