mirror of https://github.com/vuejs/core.git
wip: save
This commit is contained in:
parent
205858e8be
commit
0d950d41b5
|
@ -49,7 +49,11 @@ describe('vapor transition', () => {
|
||||||
([btnSel, containerSel]) => {
|
([btnSel, containerSel]) => {
|
||||||
;(document.querySelector(btnSel) as HTMLElement)!.click()
|
;(document.querySelector(btnSel) as HTMLElement)!.click()
|
||||||
return Promise.resolve().then(() => {
|
return Promise.resolve().then(() => {
|
||||||
return document.querySelector(containerSel)!.className.split(/\s+/g)
|
const container = document.querySelector(containerSel)!
|
||||||
|
return {
|
||||||
|
classNames: container.className.split(/\s+/g),
|
||||||
|
innerHTML: container.innerHTML,
|
||||||
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
[btnSelector, containerSelector],
|
[btnSelector, containerSelector],
|
||||||
|
@ -66,7 +70,8 @@ describe('vapor transition', () => {
|
||||||
|
|
||||||
// leave
|
// leave
|
||||||
expect(
|
expect(
|
||||||
await classWhenTransitionStart(btnSelector, containerSelector),
|
(await classWhenTransitionStart(btnSelector, containerSelector))
|
||||||
|
.classNames,
|
||||||
).toStrictEqual(['v-leave-from', 'v-leave-active'])
|
).toStrictEqual(['v-leave-from', 'v-leave-active'])
|
||||||
|
|
||||||
await nextFrame()
|
await nextFrame()
|
||||||
|
@ -80,7 +85,8 @@ describe('vapor transition', () => {
|
||||||
|
|
||||||
// enter
|
// enter
|
||||||
expect(
|
expect(
|
||||||
await classWhenTransitionStart(btnSelector, containerSelector),
|
(await classWhenTransitionStart(btnSelector, containerSelector))
|
||||||
|
.classNames,
|
||||||
).toStrictEqual(['v-enter-from', 'v-enter-active'])
|
).toStrictEqual(['v-enter-from', 'v-enter-active'])
|
||||||
|
|
||||||
await nextFrame()
|
await nextFrame()
|
||||||
|
@ -102,16 +108,14 @@ describe('vapor transition', () => {
|
||||||
const containerSelector = '.vif > h1'
|
const containerSelector = '.vif > h1'
|
||||||
|
|
||||||
// appear
|
// appear
|
||||||
expect(await classList(containerSelector)).toStrictEqual([
|
expect(await classList(containerSelector)).contains('v-enter-active')
|
||||||
'v-enter-from',
|
|
||||||
'v-enter-active',
|
|
||||||
])
|
|
||||||
expect(await text(containerSelector)).toContain('vIf')
|
expect(await text(containerSelector)).toContain('vIf')
|
||||||
await transitionFinish()
|
await transitionFinish()
|
||||||
|
|
||||||
// leave
|
// leave
|
||||||
expect(
|
expect(
|
||||||
await classWhenTransitionStart(btnSelector, containerSelector),
|
(await classWhenTransitionStart(btnSelector, containerSelector))
|
||||||
|
.classNames,
|
||||||
).toStrictEqual(['v-leave-from', 'v-leave-active'])
|
).toStrictEqual(['v-leave-from', 'v-leave-active'])
|
||||||
|
|
||||||
await nextFrame()
|
await nextFrame()
|
||||||
|
@ -125,7 +129,8 @@ describe('vapor transition', () => {
|
||||||
|
|
||||||
// enter
|
// enter
|
||||||
expect(
|
expect(
|
||||||
await classWhenTransitionStart(btnSelector, containerSelector),
|
(await classWhenTransitionStart(btnSelector, containerSelector))
|
||||||
|
.classNames,
|
||||||
).toStrictEqual(['v-enter-from', 'v-enter-active'])
|
).toStrictEqual(['v-enter-from', 'v-enter-active'])
|
||||||
|
|
||||||
await nextFrame()
|
await nextFrame()
|
||||||
|
@ -150,7 +155,8 @@ describe('vapor transition', () => {
|
||||||
|
|
||||||
// change key
|
// change key
|
||||||
expect(
|
expect(
|
||||||
await classWhenTransitionStart(btnSelector, containerSelector),
|
(await classWhenTransitionStart(btnSelector, containerSelector))
|
||||||
|
.classNames,
|
||||||
).toStrictEqual(['v-leave-from', 'v-leave-active'])
|
).toStrictEqual(['v-leave-from', 'v-leave-active'])
|
||||||
|
|
||||||
await nextFrame()
|
await nextFrame()
|
||||||
|
@ -164,7 +170,8 @@ describe('vapor transition', () => {
|
||||||
|
|
||||||
// change key again
|
// change key again
|
||||||
expect(
|
expect(
|
||||||
await classWhenTransitionStart(btnSelector, containerSelector),
|
(await classWhenTransitionStart(btnSelector, containerSelector))
|
||||||
|
.classNames,
|
||||||
).toStrictEqual(['v-leave-from', 'v-leave-active'])
|
).toStrictEqual(['v-leave-from', 'v-leave-active'])
|
||||||
|
|
||||||
await nextFrame()
|
await nextFrame()
|
||||||
|
@ -188,10 +195,10 @@ describe('vapor transition', () => {
|
||||||
expect(await html(containerSelector)).toBe(`<div>vapor compB</div>`)
|
expect(await html(containerSelector)).toBe(`<div>vapor compB</div>`)
|
||||||
|
|
||||||
// compB -> compA
|
// compB -> compA
|
||||||
await click(btnSelector)
|
expect(
|
||||||
expect(await html(containerSelector)).toBe(
|
(await classWhenTransitionStart(btnSelector, containerSelector))
|
||||||
`<div class="fade-leave-from fade-leave-active">vapor compB</div>`,
|
.innerHTML,
|
||||||
)
|
).toBe(`<div class="fade-leave-from fade-leave-active">vapor compB</div>`)
|
||||||
|
|
||||||
await nextFrame()
|
await nextFrame()
|
||||||
expect(await html(containerSelector)).toBe(
|
expect(await html(containerSelector)).toBe(
|
||||||
|
@ -241,7 +248,51 @@ describe('vapor transition', () => {
|
||||||
E2E_TIMEOUT,
|
E2E_TIMEOUT,
|
||||||
)
|
)
|
||||||
|
|
||||||
test.todo('should work with in-out mode', async () => {}, E2E_TIMEOUT)
|
test.todo(
|
||||||
|
'should work with in-out mode',
|
||||||
|
async () => {
|
||||||
|
const btnSelector = '.in-out > button'
|
||||||
|
const containerSelector = '.in-out > div'
|
||||||
|
|
||||||
|
expect(await html(containerSelector)).toBe(`<div>vapor compB</div>`)
|
||||||
|
|
||||||
|
// compA enter
|
||||||
|
const { innerHTML } = await classWhenTransitionStart(
|
||||||
|
btnSelector,
|
||||||
|
containerSelector,
|
||||||
|
)
|
||||||
|
expect(innerHTML).toBe(
|
||||||
|
`<div>vapor compB</div><div class="fade-enter-from fade-enter-active">vapor compA</div>`,
|
||||||
|
)
|
||||||
|
|
||||||
|
await nextFrame()
|
||||||
|
expect(await html(containerSelector)).toBe(
|
||||||
|
`<div>vapor compB</div><div class="fade-enter-active fade-enter-to">vapor compA</div>`,
|
||||||
|
)
|
||||||
|
|
||||||
|
await transitionFinish()
|
||||||
|
expect(await html(containerSelector)).toBe(
|
||||||
|
`<div>vapor compB</div><div class="">vapor compA</div>`,
|
||||||
|
)
|
||||||
|
|
||||||
|
// compB leave
|
||||||
|
expect(await html(containerSelector)).toBe(
|
||||||
|
`<div class="fade-leave-from fade-leave-active">vapor compB</div><div class="">vapor compA</div>`,
|
||||||
|
)
|
||||||
|
|
||||||
|
await nextFrame()
|
||||||
|
expect(await html(containerSelector)).toBe(
|
||||||
|
`<div class="fade-leave-active fade-leave-to">vapor compB</div><div class="">vapor compA</div>`,
|
||||||
|
)
|
||||||
|
|
||||||
|
await transitionFinish()
|
||||||
|
await nextFrame()
|
||||||
|
expect(await html(containerSelector)).toBe(
|
||||||
|
`<div class="">vapor compA</div>`,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
E2E_TIMEOUT,
|
||||||
|
)
|
||||||
|
|
||||||
test.todo('transition hooks', async () => {}, E2E_TIMEOUT)
|
test.todo('transition hooks', async () => {}, E2E_TIMEOUT)
|
||||||
|
|
||||||
|
|
|
@ -33,13 +33,21 @@ function toggleComponent() {
|
||||||
</Transition>
|
</Transition>
|
||||||
</div>
|
</div>
|
||||||
<div class="out-in">
|
<div class="out-in">
|
||||||
<button @click="toggleComponent">toggle component</button>
|
<button @click="toggleComponent">toggle out-in</button>
|
||||||
<div>
|
<div>
|
||||||
<Transition name="fade" mode="out-in">
|
<Transition name="fade" mode="out-in">
|
||||||
<component :is="activeComponent"></component>
|
<component :is="activeComponent"></component>
|
||||||
</Transition>
|
</Transition>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="in-out">
|
||||||
|
<button @click="toggleComponent">toggle in-out</button>
|
||||||
|
<div>
|
||||||
|
<Transition name="fade" mode="in-out">
|
||||||
|
<component :is="activeComponent"></component>
|
||||||
|
</Transition>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<style>
|
<style>
|
||||||
.keyed {
|
.keyed {
|
||||||
|
|
|
@ -130,9 +130,7 @@ function transformComponentElement(
|
||||||
}
|
}
|
||||||
|
|
||||||
context.dynamic.flags |= DynamicFlag.NON_TEMPLATE | DynamicFlag.INSERT
|
context.dynamic.flags |= DynamicFlag.NON_TEMPLATE | DynamicFlag.INSERT
|
||||||
// context.registerOperation()
|
context.registerOperation({
|
||||||
// TODO revert wait for https://github.com/vuejs/core/pull/12951 get merged
|
|
||||||
context.block.operation.unshift({
|
|
||||||
type: IRNodeTypes.CREATE_COMPONENT_NODE,
|
type: IRNodeTypes.CREATE_COMPONENT_NODE,
|
||||||
id: context.reference(),
|
id: context.reference(),
|
||||||
tag,
|
tag,
|
||||||
|
|
|
@ -210,6 +210,7 @@ export function findTransitionBlock(block: Block): TransitionBlock | undefined {
|
||||||
if (block instanceof Element) child = block
|
if (block instanceof Element) child = block
|
||||||
} else if (isVaporComponent(block)) {
|
} else if (isVaporComponent(block)) {
|
||||||
child = findTransitionBlock(block.block)
|
child = findTransitionBlock(block.block)
|
||||||
|
if (child && child.key === undefined) child.key = block.type.__name
|
||||||
} else if (Array.isArray(block)) {
|
} else if (Array.isArray(block)) {
|
||||||
child = block[0] as TransitionBlock
|
child = block[0] as TransitionBlock
|
||||||
let hasFound = false
|
let hasFound = false
|
||||||
|
|
Loading…
Reference in New Issue