Skip to content

Commit

Permalink
Postpone running the hooks after they've all been registered
Browse files Browse the repository at this point in the history
  • Loading branch information
pygy committed Aug 2, 2016
1 parent caf6ea7 commit c9251fc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions render/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,12 @@ module.exports = function($window) {
var callback = function() {
if (++called === expected) removeNode(parent, vnode, context, true)
}
var removables = [vnode]
var removables = [vnode], hooks = []
while (removables[0]) {
var removable = removables.shift()

if (removable.attrs && removable.attrs.onbeforeremove) {
expected++
removable.attrs.onbeforeremove.call(removable.state, removable, callback)
hooks.push(removable.attrs.onbeforeremove.bind(removable.state, removable, callback))
}
if (removable.tag && typeof removable.tag !== "string" && removable.tag.onbeforeremove) {
expected++
Expand All @@ -353,6 +352,7 @@ module.exports = function($window) {
}
}
}
for (var i = 0; i < hooks.length; i++) hooks[i]()
if (expected > 0) return
}

Expand Down

0 comments on commit c9251fc

Please sign in to comment.