fix transition insert hook duplicate invocation on slot nodes (fix #3474)

This commit is contained in:
Evan You 2016-08-18 12:00:31 -04:00
parent 6bdb577d4a
commit ba5fb31188
2 changed files with 11 additions and 3 deletions

View File

@ -46,6 +46,7 @@ declare interface VNodeData {
on?: ?{ [key: string]: Function | Array<Function> };
nativeOn?: { [key: string]: Function | Array<Function> };
transition?: Object;
transitionInjected?: boolean;
inlineTemplate?: {
render: Function;
staticRenderFns: Array<Function>;

View File

@ -94,14 +94,21 @@ export function enter (vnode: VNodeWithData) {
if (!vnode.data.show) {
// remove pending leave element on enter by injecting an insert hook
mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'insert', () => {
const hooks = vnode.data.hook || (vnode.data.hook = {})
hooks._transitionInsert = () => {
const parent = el.parentNode
const pendingNode = parent._pending && parent._pending[vnode.key]
const pendingNode = parent && parent._pending && parent._pending[vnode.key]
if (pendingNode && pendingNode.tag === vnode.tag && pendingNode.elm._leaveCb) {
pendingNode.elm._leaveCb()
}
enterHook && enterHook(el, cb)
})
}
if (!vnode.data.transitionInjected) {
vnode.data.transitionInjected = true
mergeVNodeHook(hooks, 'insert', () => {
hooks._transitionInsert()
})
}
}
// start enter transition