mirror of https://github.com/vuejs/core.git
fix(hydration): handle appear transition before patch props (#9837)
close #9832
This commit is contained in:
parent
0a387dfb1d
commit
e70f4c47c5
|
@ -1114,6 +1114,41 @@ describe('SSR hydration', () => {
|
||||||
expect(`mismatch`).not.toHaveBeenWarned()
|
expect(`mismatch`).not.toHaveBeenWarned()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('transition appear w/ event listener', async () => {
|
||||||
|
const container = document.createElement('div')
|
||||||
|
container.innerHTML = `<template><button>0</button></template>`
|
||||||
|
createSSRApp({
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
count: 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
template: `
|
||||||
|
<Transition appear>
|
||||||
|
<button @click="count++">{{count}}</button>
|
||||||
|
</Transition>
|
||||||
|
`
|
||||||
|
}).mount(container)
|
||||||
|
|
||||||
|
expect(container.firstChild).toMatchInlineSnapshot(`
|
||||||
|
<button
|
||||||
|
class="v-enter-from v-enter-active"
|
||||||
|
>
|
||||||
|
0
|
||||||
|
</button>
|
||||||
|
`)
|
||||||
|
|
||||||
|
triggerEvent('click', container.querySelector('button')!)
|
||||||
|
await nextTick()
|
||||||
|
expect(container.firstChild).toMatchInlineSnapshot(`
|
||||||
|
<button
|
||||||
|
class="v-enter-from v-enter-active"
|
||||||
|
>
|
||||||
|
1
|
||||||
|
</button>
|
||||||
|
`)
|
||||||
|
})
|
||||||
|
|
||||||
describe('mismatch handling', () => {
|
describe('mismatch handling', () => {
|
||||||
test('text node', () => {
|
test('text node', () => {
|
||||||
const { container } = mountWithHydration(`foo`, () => 'bar')
|
const { container } = mountWithHydration(`foo`, () => 'bar')
|
||||||
|
|
|
@ -344,6 +344,28 @@ export function createHydrationFunctions(
|
||||||
if (dirs) {
|
if (dirs) {
|
||||||
invokeDirectiveHook(vnode, null, parentComponent, 'created')
|
invokeDirectiveHook(vnode, null, parentComponent, 'created')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handle appear transition
|
||||||
|
let needCallTransitionHooks = false
|
||||||
|
if (isTemplateNode(el)) {
|
||||||
|
needCallTransitionHooks =
|
||||||
|
needTransition(parentSuspense, transition) &&
|
||||||
|
parentComponent &&
|
||||||
|
parentComponent.vnode.props &&
|
||||||
|
parentComponent.vnode.props.appear
|
||||||
|
|
||||||
|
const content = (el as HTMLTemplateElement).content
|
||||||
|
.firstChild as Element
|
||||||
|
|
||||||
|
if (needCallTransitionHooks) {
|
||||||
|
transition!.beforeEnter(content)
|
||||||
|
}
|
||||||
|
|
||||||
|
// replace <template> node with inner children
|
||||||
|
replaceNode(content, el, parentComponent)
|
||||||
|
vnode.el = el = content
|
||||||
|
}
|
||||||
|
|
||||||
// props
|
// props
|
||||||
if (props) {
|
if (props) {
|
||||||
if (
|
if (
|
||||||
|
@ -390,27 +412,6 @@ export function createHydrationFunctions(
|
||||||
invokeVNodeHook(vnodeHooks, parentComponent, vnode)
|
invokeVNodeHook(vnodeHooks, parentComponent, vnode)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle appear transition
|
|
||||||
let needCallTransitionHooks = false
|
|
||||||
if (isTemplateNode(el)) {
|
|
||||||
needCallTransitionHooks =
|
|
||||||
needTransition(parentSuspense, transition) &&
|
|
||||||
parentComponent &&
|
|
||||||
parentComponent.vnode.props &&
|
|
||||||
parentComponent.vnode.props.appear
|
|
||||||
|
|
||||||
const content = (el as HTMLTemplateElement).content
|
|
||||||
.firstChild as Element
|
|
||||||
|
|
||||||
if (needCallTransitionHooks) {
|
|
||||||
transition!.beforeEnter(content)
|
|
||||||
}
|
|
||||||
|
|
||||||
// replace <template> node with inner children
|
|
||||||
replaceNode(content, el, parentComponent)
|
|
||||||
vnode.el = el = content
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dirs) {
|
if (dirs) {
|
||||||
invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount')
|
invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount')
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue