mirror of
https://gitee.com/vuejs/vue.git
synced 2024-11-30 02:57:43 +08:00
fix transition remove
This commit is contained in:
parent
050395408a
commit
aaa334d08f
@ -1,5 +1,5 @@
|
||||
import { isIE9 } from '../util/index'
|
||||
import { beforeEnter, onLeave } from '../vdom-web/modules/transition'
|
||||
import { enter, leave } from '../vdom-web/modules/transition'
|
||||
|
||||
export default {
|
||||
bind (el, value) {
|
||||
@ -12,10 +12,10 @@ export default {
|
||||
: vnode.data.transition
|
||||
if (!isIE9 && transition != null) {
|
||||
if (value) {
|
||||
beforeEnter(null, vnode)
|
||||
enter(vnode)
|
||||
el.style.display = ''
|
||||
} else {
|
||||
onLeave(vnode, () => {
|
||||
leave(vnode, () => {
|
||||
el.style.display = 'none'
|
||||
})
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ function nextFrame (fn) {
|
||||
})
|
||||
}
|
||||
|
||||
export function beforeEnter (_, vnode) {
|
||||
export function enter (vnode) {
|
||||
const el = vnode.elm
|
||||
// call leave callback now
|
||||
if (el._leaveCb) {
|
||||
@ -84,7 +84,7 @@ export function beforeEnter (_, vnode) {
|
||||
}
|
||||
}
|
||||
|
||||
export function onLeave (vnode, rm) {
|
||||
export function leave (vnode, rm) {
|
||||
const el = vnode.elm
|
||||
// call enter callback now
|
||||
if (el._enterCb) {
|
||||
@ -235,24 +235,28 @@ function once (fn) {
|
||||
}
|
||||
}
|
||||
|
||||
function guardHook (hook, getVnode) {
|
||||
return function guardedTransitionHook (_, __) {
|
||||
const vnode = getVnode(_, __)
|
||||
function shouldSkipTransition (vnode) {
|
||||
return (
|
||||
// if this is a component root node and the compoennt's
|
||||
// parent container node also has transition, skip.
|
||||
if (vnode.parent && vnode.parent.data.transition) {
|
||||
return
|
||||
}
|
||||
(vnode.parent && vnode.parent.data.transition) ||
|
||||
// if the element has v-show, let the runtime directive
|
||||
// call the hooks instead
|
||||
if (vnode.data.show) {
|
||||
return
|
||||
}
|
||||
hook(_, __)
|
||||
}
|
||||
vnode.data.show
|
||||
)
|
||||
}
|
||||
|
||||
export default !transitionEndEvent ? {} : {
|
||||
create: guardHook(beforeEnter, (_, vnode) => vnode),
|
||||
remove: guardHook(onLeave, vnode => vnode)
|
||||
create: function (_, vnode) {
|
||||
if (!shouldSkipTransition(vnode)) {
|
||||
enter(vnode)
|
||||
}
|
||||
},
|
||||
remove: function (vnode, rm) {
|
||||
if (!shouldSkipTransition(vnode)) {
|
||||
leave(vnode, rm)
|
||||
} else {
|
||||
rm()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user