return extend(baseProps, {
onBeforeEnter(el) {
onBeforeEnter && onBeforeEnter(el)
- addTransitionClass(el, enterActiveClass)
addTransitionClass(el, enterFromClass)
+ addTransitionClass(el, enterActiveClass)
},
onBeforeAppear(el) {
onBeforeAppear && onBeforeAppear(el)
- addTransitionClass(el, appearActiveClass)
addTransitionClass(el, appearFromClass)
+ addTransitionClass(el, appearActiveClass)
},
onEnter: makeEnterHook(false),
onAppear: makeEnterHook(true),
onLeave(el, done) {
const resolve = () => finishLeave(el, done)
- addTransitionClass(el, leaveActiveClass)
addTransitionClass(el, leaveFromClass)
-
- const cachedTransition = (el as HTMLElement).style.transitionProperty
- requestAnimationFrame(() => {
- // ref #2531, #2593
- // disabling the transition before nextFrame ensures styles from
- // *-leave-from classes are applied instantly before the transition starts.
- // ref #2712
- // do this in an rAF to ensure styles from *-leave-active can trigger
- // transition on the first frame when el has `transition` property itself.
- ;(el as HTMLElement).style.transitionProperty = 'none'
- })
+ // force reflow so *-leave-from classes immediately take effect (#2593)
+ forceReflow()
+ addTransitionClass(el, leaveActiveClass)
nextFrame(() => {
- ;(el as HTMLElement).style.transitionProperty = cachedTransition
removeTransitionClass(el, leaveFromClass)
addTransitionClass(el, leaveToClass)
if (!(onLeave && onLeave.length > 1)) {
function toMs(s: string): number {
return Number(s.slice(0, -1).replace(',', '.')) * 1000
}
+
+// synchronously force layout to put elements into a certain state
+export function forceReflow() {
+ return document.body.offsetHeight
+}
// leave
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'v-leave-active',
- 'v-leave-from'
+ 'v-leave-from',
+ 'v-leave-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
// enter
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'v-enter-active',
- 'v-enter-from'
+ 'v-enter-from',
+ 'v-enter-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
// leave
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'test-leave-active',
- 'test-leave-from'
+ 'test-leave-from',
+ 'test-leave-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
// enter
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'test-enter-active',
- 'test-enter-from'
+ 'test-enter-from',
+ 'test-enter-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
// leave
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'bye-active',
- 'bye-from'
+ 'bye-from',
+ 'bye-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
// enter
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'hello-active',
- 'hello-from'
+ 'hello-from',
+ 'hello-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
// leave
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'test-leave-active',
- 'test-leave-from'
+ 'test-leave-from',
+ 'test-leave-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
})
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'changed-enter-active',
- 'changed-enter-from'
+ 'changed-enter-from',
+ 'changed-enter-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
// leave
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'test-leave-active',
- 'test-leave-from'
+ 'test-leave-from',
+ 'test-leave-active'
])
// todo test event with arguments. Note: not get dom, get object. '{}'
expect(beforeLeaveSpy).toBeCalled()
// enter
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'test-enter-active',
- 'test-enter-from'
+ 'test-enter-from',
+ 'test-enter-active'
])
expect(beforeEnterSpy).toBeCalled()
expect(onEnterSpy).toBeCalled()
// enter
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'test-enter-active',
- 'test-enter-from'
+ 'test-enter-from',
+ 'test-enter-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
// cancel (leave)
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'test-leave-active',
- 'test-leave-from'
+ 'test-leave-from',
+ 'test-leave-active'
])
expect(enterCancelledSpy).toBeCalled()
await nextFrame()
// appear
expect(appearClass).toStrictEqual([
'test',
- 'test-appear-active',
- 'test-appear-from'
+ 'test-appear-from',
+ 'test-appear-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
// leave
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'test-leave-active',
- 'test-leave-from'
+ 'test-leave-from',
+ 'test-leave-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
// enter
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'test-enter-active',
- 'test-enter-from'
+ 'test-enter-from',
+ 'test-enter-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
// appear
expect(appearClass).toStrictEqual([
'test',
- 'test-appear-active',
- 'test-appear-from'
+ 'test-appear-from',
+ 'test-appear-active'
])
expect(beforeAppearSpy).toBeCalled()
expect(onAppearSpy).toBeCalled()
// leave
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'test-leave-active',
- 'test-leave-from'
+ 'test-leave-from',
+ 'test-leave-active'
])
expect(beforeLeaveSpy).toBeCalled()
expect(onLeaveSpy).toBeCalled()
// enter
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'test-enter-active',
- 'test-enter-from'
+ 'test-enter-from',
+ 'test-enter-active'
])
expect(beforeEnterSpy).toBeCalled()
expect(onEnterSpy).toBeCalled()
// leave
expect(await classWhenTransitionStart()).toStrictEqual([
- 'noop-leave-active',
- 'noop-leave-from'
+ 'noop-leave-from',
+ 'noop-leave-active'
])
await nextFrame()
expect(await html('#container')).toBe('<!--v-if-->')
// enter
expect(await classWhenTransitionStart()).toStrictEqual([
- 'noop-enter-active',
- 'noop-enter-from'
+ 'noop-enter-from',
+ 'noop-enter-active'
])
await nextFrame()
expect(await html('#container')).toBe('<div class="">content</div>')
// leave
expect(await classWhenTransitionStart()).toStrictEqual([
- 'test-anim-leave-active',
- 'test-anim-leave-from'
+ 'test-anim-leave-from',
+ 'test-anim-leave-active'
])
await nextFrame()
expect(await classList('#container div')).toStrictEqual([
// enter
expect(await classWhenTransitionStart()).toStrictEqual([
- 'test-anim-enter-active',
- 'test-anim-enter-from'
+ 'test-anim-enter-from',
+ 'test-anim-enter-active'
])
await nextFrame()
expect(await classList('#container div')).toStrictEqual([
// leave
expect(await classWhenTransitionStart()).toStrictEqual([
- 'test-anim-long-leave-active',
- 'test-anim-long-leave-from'
+ 'test-anim-long-leave-from',
+ 'test-anim-long-leave-active'
])
await nextFrame()
expect(await classList('#container div')).toStrictEqual([
// enter
expect(await classWhenTransitionStart()).toStrictEqual([
- 'test-anim-long-enter-active',
- 'test-anim-long-enter-from'
+ 'test-anim-long-enter-from',
+ 'test-anim-long-enter-active'
])
await nextFrame()
expect(await classList('#container div')).toStrictEqual([
// leave
expect(await svgTransitionStart()).toStrictEqual([
'test',
- 'test-leave-active',
- 'test-leave-from'
+ 'test-leave-from',
+ 'test-leave-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
// enter
expect(await svgTransitionStart()).toStrictEqual([
'test',
- 'test-enter-active',
- 'test-enter-from'
+ 'test-enter-from',
+ 'test-enter-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
// leave
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'test-leave-active',
- 'test-leave-from'
+ 'test-leave-from',
+ 'test-leave-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
// enter
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'test-enter-active',
- 'test-enter-from'
+ 'test-enter-from',
+ 'test-enter-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
// enter
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'test-enter-active',
- 'test-enter-from'
+ 'test-enter-from',
+ 'test-enter-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
// leave
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'test-leave-active',
- 'test-leave-from'
+ 'test-leave-from',
+ 'test-leave-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
// leave
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'v-leave-active',
- 'v-leave-from'
+ 'v-leave-from',
+ 'v-leave-active'
])
expect(onLeaveSpy).toBeCalledTimes(1)
await nextFrame()
})
expect(enterClass).toStrictEqual([
'test',
- 'v-enter-active',
- 'v-enter-from'
+ 'v-enter-from',
+ 'v-enter-active'
])
expect(onEnterSpy).toBeCalledTimes(2)
await nextFrame()
// leave
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'v-leave-active',
- 'v-leave-from'
+ 'v-leave-from',
+ 'v-leave-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
// enter
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'v-enter-active',
- 'v-enter-from'
+ 'v-enter-from',
+ 'v-enter-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
await classWhenTransitionStart()
await nextFrame()
expect(await html('#container')).toBe(
- '<div class="test v-leave-active v-leave-to" style="">one</div>'
+ '<div class="test v-leave-active v-leave-to">one</div>'
)
await transitionFinish()
await nextFrame()
// leave
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'test-leave-active',
- 'test-leave-from'
+ 'test-leave-from',
+ 'test-leave-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
// enter
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'test-enter-active',
- 'test-enter-from'
+ 'test-enter-from',
+ 'test-enter-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
// leave
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'test-leave-active',
- 'test-leave-from'
+ 'test-leave-from',
+ 'test-leave-active'
])
expect(beforeLeaveSpy).toBeCalled()
expect(onLeaveSpy).toBeCalled()
// enter
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'test-enter-active',
- 'test-enter-from'
+ 'test-enter-from',
+ 'test-enter-active'
])
expect(beforeEnterSpy).toBeCalled()
expect(onEnterSpy).toBeCalled()
// leave
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'test-leave-active',
- 'test-leave-from'
+ 'test-leave-from',
+ 'test-leave-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
// cancel (enter)
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'test-enter-active',
- 'test-enter-from'
+ 'test-enter-from',
+ 'test-enter-active'
])
expect(onLeaveCancelledSpy).toBeCalled()
await nextFrame()
// appear
expect(appearClass).toStrictEqual([
'test',
- 'test-appear-active',
- 'test-appear-from'
+ 'test-appear-from',
+ 'test-appear-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
// leave
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'test-leave-active',
- 'test-leave-from'
+ 'test-leave-from',
+ 'test-leave-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
// enter
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'test-enter-active',
- 'test-enter-from'
+ 'test-enter-from',
+ 'test-enter-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
// leave
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'test-leave-active',
- 'test-leave-from'
+ 'test-leave-from',
+ 'test-leave-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
// enter
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'test-enter-active',
- 'test-enter-from'
+ 'test-enter-from',
+ 'test-enter-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
// leave
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'test-leave-active',
- 'test-leave-from'
+ 'test-leave-from',
+ 'test-leave-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
// enter
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'test-enter-active',
- 'test-enter-from'
+ 'test-enter-from',
+ 'test-enter-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
// leave
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'test-leave-active',
- 'test-leave-from'
+ 'test-leave-from',
+ 'test-leave-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
// enter
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'test-enter-active',
- 'test-enter-from'
+ 'test-enter-from',
+ 'test-enter-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
// leave
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'test-leave-active',
- 'test-leave-from'
+ 'test-leave-from',
+ 'test-leave-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
// enter
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
- 'test-enter-active',
- 'test-enter-from'
+ 'test-enter-from',
+ 'test-enter-active'
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
`<div class="test">a</div>` +
`<div class="test">b</div>` +
`<div class="test">c</div>` +
- `<div class="test test-enter-active test-enter-from">d</div>` +
- `<div class="test test-enter-active test-enter-from">e</div>`
+ `<div class="test test-enter-from test-enter-active">d</div>` +
+ `<div class="test test-enter-from test-enter-active">e</div>`
)
await nextFrame()
expect(await html('#container')).toBe(
)
expect(await htmlWhenTransitionStart()).toBe(
- `<div class="test test-leave-active test-leave-from">a</div>` +
+ `<div class="test test-leave-from test-leave-active">a</div>` +
`<div class="test">b</div>` +
- `<div class="test test-leave-active test-leave-from">c</div>`
+ `<div class="test test-leave-from test-leave-active">c</div>`
)
await nextFrame()
expect(await html('#container')).toBe(
- `<div class="test test-leave-active test-leave-to" style="">a</div>` +
+ `<div class="test test-leave-active test-leave-to">a</div>` +
`<div class="test">b</div>` +
- `<div class="test test-leave-active test-leave-to" style="">c</div>`
+ `<div class="test test-leave-active test-leave-to">c</div>`
)
await transitionFinish()
expect(await html('#container')).toBe(`<div class="test">b</div>`)
)
expect(await htmlWhenTransitionStart()).toBe(
- `<div class="test test-leave-active test-leave-from">a</div>` +
+ `<div class="test test-leave-from test-leave-active">a</div>` +
`<div class="test">b</div>` +
`<div class="test">c</div>` +
- `<div class="test test-enter-active test-enter-from">d</div>`
+ `<div class="test test-enter-from test-enter-active">d</div>`
)
await nextFrame()
expect(await html('#container')).toBe(
- `<div class="test test-leave-active test-leave-to" style="">a</div>` +
+ `<div class="test test-leave-active test-leave-to">a</div>` +
`<div class="test">b</div>` +
`<div class="test">c</div>` +
`<div class="test test-enter-active test-enter-to">d</div>`
})
// appear
expect(appearHtml).toBe(
- `<div class="test test-appear-active test-appear-from">a</div>` +
- `<div class="test test-appear-active test-appear-from">b</div>` +
- `<div class="test test-appear-active test-appear-from">c</div>`
+ `<div class="test test-appear-from test-appear-active">a</div>` +
+ `<div class="test test-appear-from test-appear-active">b</div>` +
+ `<div class="test test-appear-from test-appear-active">c</div>`
)
await nextFrame()
expect(await html('#container')).toBe(
`<div class="test">a</div>` +
`<div class="test">b</div>` +
`<div class="test">c</div>` +
- `<div class="test test-enter-active test-enter-from">d</div>` +
- `<div class="test test-enter-active test-enter-from">e</div>`
+ `<div class="test test-enter-from test-enter-active">d</div>` +
+ `<div class="test test-enter-from test-enter-active">e</div>`
)
await nextFrame()
expect(await html('#container')).toBe(
)
expect(await htmlWhenTransitionStart()).toBe(
- `<div class="test group-enter-active group-enter-from">d</div>` +
+ `<div class="test group-enter-from group-enter-active">d</div>` +
`<div class="test">b</div>` +
`<div class="test group-move" style="">a</div>` +
- `<div class="test group-leave-active group-leave-from group-move" style="">c</div>`
+ `<div class="test group-leave-from group-leave-active group-move" style="">c</div>`
)
await nextFrame()
expect(await html('#container')).toBe(
expect(onAppearSpy).toBeCalled()
expect(afterAppearSpy).not.toBeCalled()
expect(appearHtml).toBe(
- `<div class="test test-appear-active test-appear-from">a</div>` +
- `<div class="test test-appear-active test-appear-from">b</div>` +
- `<div class="test test-appear-active test-appear-from">c</div>`
+ `<div class="test test-appear-from test-appear-active">a</div>` +
+ `<div class="test test-appear-from test-appear-active">b</div>` +
+ `<div class="test test-appear-from test-appear-active">c</div>`
)
await nextFrame()
expect(afterAppearSpy).not.toBeCalled()
// enter + leave
expect(await htmlWhenTransitionStart()).toBe(
- `<div class="test test-leave-active test-leave-from">a</div>` +
+ `<div class="test test-leave-from test-leave-active">a</div>` +
`<div class="test">b</div>` +
`<div class="test">c</div>` +
- `<div class="test test-enter-active test-enter-from">d</div>`
+ `<div class="test test-enter-from test-enter-active">d</div>`
)
expect(beforeLeaveSpy).toBeCalled()
expect(onLeaveSpy).toBeCalled()
expect(afterEnterSpy).not.toBeCalled()
await nextFrame()
expect(await html('#container')).toBe(
- `<div class="test test-leave-active test-leave-to" style="">a</div>` +
+ `<div class="test test-leave-active test-leave-to">a</div>` +
`<div class="test">b</div>` +
`<div class="test">c</div>` +
`<div class="test test-enter-active test-enter-to">d</div>`