Skip to content

Commit 3f91f65

Browse files
committed
fix id-resolved appear transition (fix vuejs#3157)
1 parent 1d02463 commit 3f91f65

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

src/platforms/web/runtime/modules/transition.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,15 @@ export function enter (vnode: VNodeWithData) {
4242
el._leaveCb.cancelled = true
4343
el._leaveCb()
4444
}
45+
4546
const data = vnode.data.transition
4647
if (!data) {
4748
return
4849
}
49-
const isAppear = !vnode.context.$root._isMounted
50-
if (isAppear && !data.appear && data.appear !== '') {
51-
return
52-
}
5350

5451
const {
5552
css,
53+
appear,
5654
enterClass,
5755
enterActiveClass,
5856
appearClass,
@@ -67,6 +65,11 @@ export function enter (vnode: VNodeWithData) {
6765
appearCancelled
6866
} = resolveTransition(data, vnode.context)
6967

68+
const isAppear = !vnode.context.$root._isMounted
69+
if (isAppear && !appear && appear !== '') {
70+
return
71+
}
72+
7073
const startClass = isAppear ? appearClass : enterClass
7174
const activeClass = isAppear ? appearActiveClass : enterActiveClass
7275
const beforeEnterHook = isAppear ? (beforeAppear || beforeEnter) : beforeEnter

test/unit/features/transition/transition.spec.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ if (!isIE9) {
426426
}).then(done)
427427
})
428428

429-
it('transition on appear', done => {
429+
it('transition on appear (inline)', done => {
430430
const vm = new Vue({
431431
template: `
432432
<div>
@@ -452,6 +452,34 @@ if (!isIE9) {
452452
}).then(done)
453453
})
454454

455+
it('transition on appear (resolved)', done => {
456+
const vm = new Vue({
457+
template: `
458+
<div>
459+
<div v-if="ok"
460+
class="test"
461+
transition="test">foo</div>
462+
</div>
463+
`,
464+
data: { ok: true },
465+
transitions: {
466+
test: {
467+
appear: true,
468+
appearClass: 'test-appear',
469+
appearActiveClass: 'test-appear-active'
470+
}
471+
}
472+
}).$mount(el)
473+
474+
waitForUpdate(() => {
475+
expect(vm.$el.children[0].className).toBe('test test-appear test-appear-active')
476+
}).thenWaitFor(nextFrame).then(() => {
477+
expect(vm.$el.children[0].className).toBe('test test-appear-active')
478+
}).thenWaitFor(duration + 10).then(() => {
479+
expect(vm.$el.children[0].className).toBe('test')
480+
}).then(done)
481+
})
482+
455483
it('transition on appear with v-show', done => {
456484
const vm = new Vue({
457485
template: `

0 commit comments

Comments
 (0)