Only call onremove and onbeforeremove when they are functions. Fix #1706
This commit is contained in:
parent
f7450c96b0
commit
e20fd3f876
1 changed files with 4 additions and 4 deletions
|
|
@ -406,14 +406,14 @@ module.exports = function($window) {
|
||||||
}
|
}
|
||||||
function removeNode(vnode, context) {
|
function removeNode(vnode, context) {
|
||||||
var expected = 1, called = 0
|
var expected = 1, called = 0
|
||||||
if (vnode.attrs && vnode.attrs.onbeforeremove) {
|
if (vnode.attrs && typeof vnode.attrs.onbeforeremove === "function") {
|
||||||
var result = vnode.attrs.onbeforeremove.call(vnode.state, vnode)
|
var result = vnode.attrs.onbeforeremove.call(vnode.state, vnode)
|
||||||
if (result != null && typeof result.then === "function") {
|
if (result != null && typeof result.then === "function") {
|
||||||
expected++
|
expected++
|
||||||
result.then(continuation, continuation)
|
result.then(continuation, continuation)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (typeof vnode.tag !== "string" && vnode._state.onbeforeremove) {
|
if (typeof vnode.tag !== "string" && typeof vnode._state.onbeforeremove === "function") {
|
||||||
var result = vnode._state.onbeforeremove.call(vnode.state, vnode)
|
var result = vnode._state.onbeforeremove.call(vnode.state, vnode)
|
||||||
if (result != null && typeof result.then === "function") {
|
if (result != null && typeof result.then === "function") {
|
||||||
expected++
|
expected++
|
||||||
|
|
@ -446,8 +446,8 @@ module.exports = function($window) {
|
||||||
if (parent != null) parent.removeChild(node)
|
if (parent != null) parent.removeChild(node)
|
||||||
}
|
}
|
||||||
function onremove(vnode) {
|
function onremove(vnode) {
|
||||||
if (vnode.attrs && vnode.attrs.onremove) vnode.attrs.onremove.call(vnode.state, vnode)
|
if (vnode.attrs && typeof vnode.attrs.onremove === "function") vnode.attrs.onremove.call(vnode.state, vnode)
|
||||||
if (typeof vnode.tag !== "string" && vnode._state.onremove) vnode._state.onremove.call(vnode.state, vnode)
|
if (typeof vnode.tag !== "string" && typeof vnode._state.onremove === "function") vnode._state.onremove.call(vnode.state, vnode)
|
||||||
if (vnode.instance != null) onremove(vnode.instance)
|
if (vnode.instance != null) onremove(vnode.instance)
|
||||||
else {
|
else {
|
||||||
var children = vnode.children
|
var children = vnode.children
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue