Simplify element removal to save a few bytes
It's also a minor peephole optimization, but I saw bigger size wins, so I'm citing that.
This commit is contained in:
parent
fa4ad79d89
commit
62eb081a13
2 changed files with 4 additions and 11 deletions
|
|
@ -643,22 +643,14 @@ module.exports = function($window) {
|
|||
checkState(vnode, original)
|
||||
onremove(vnode)
|
||||
if (vnode.dom) {
|
||||
var parent = vnode.dom.parentNode
|
||||
var count = vnode.domSize || 1
|
||||
if (count > 1) {
|
||||
var dom = vnode.dom
|
||||
while (--count) {
|
||||
removeNodeFromDOM(dom.nextSibling)
|
||||
}
|
||||
}
|
||||
removeNodeFromDOM(vnode.dom)
|
||||
while (--count) parent.removeChild(vnode.dom.nextSibling)
|
||||
parent.removeChild(vnode.dom)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function removeNodeFromDOM(node) {
|
||||
var parent = node.parentNode
|
||||
if (parent != null) parent.removeChild(node)
|
||||
}
|
||||
function onremove(vnode) {
|
||||
if (vnode.attrs && typeof vnode.attrs.onremove === "function") callHook.call(vnode.attrs.onremove, vnode)
|
||||
if (typeof vnode.tag !== "string") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue