mirror of https://github.com/vuejs/core.git
Merge 8f82270fe1
into ba391f5fdf
This commit is contained in:
commit
05375883ff
|
@ -1677,6 +1677,35 @@ describe('SSR hydration', () => {
|
||||||
expect(`mismatch`).not.toHaveBeenWarned()
|
expect(`mismatch`).not.toHaveBeenWarned()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// #13394
|
||||||
|
test('transition appear work with empty content', async () => {
|
||||||
|
const show = ref(true)
|
||||||
|
const { vnode, container } = mountWithHydration(
|
||||||
|
`<template><!----></template>`,
|
||||||
|
function (this: any) {
|
||||||
|
return h(
|
||||||
|
Transition,
|
||||||
|
{ appear: true },
|
||||||
|
{
|
||||||
|
default: () =>
|
||||||
|
show.value
|
||||||
|
? renderSlot(this.$slots, 'default')
|
||||||
|
: createTextVNode('foo'),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
// empty slot render as a comment node
|
||||||
|
expect(container.firstChild!.nodeType).toBe(Node.COMMENT_NODE)
|
||||||
|
expect(vnode.el).toBe(container.firstChild)
|
||||||
|
expect(`mismatch`).not.toHaveBeenWarned()
|
||||||
|
|
||||||
|
show.value = false
|
||||||
|
await nextTick()
|
||||||
|
expect(container.innerHTML).toBe('foo')
|
||||||
|
})
|
||||||
|
|
||||||
test('transition appear with v-if', () => {
|
test('transition appear with v-if', () => {
|
||||||
const show = false
|
const show = false
|
||||||
const { vnode, container } = mountWithHydration(
|
const { vnode, container } = mountWithHydration(
|
||||||
|
|
|
@ -111,26 +111,106 @@ describe('ssr: slot', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('transition slot', async () => {
|
test('transition slot', async () => {
|
||||||
|
const ReusableTransition = {
|
||||||
|
template: `<transition><slot/></transition>`,
|
||||||
|
}
|
||||||
|
|
||||||
|
const ReusableTransitionWithAppear = {
|
||||||
|
template: `<transition appear><slot/></transition>`,
|
||||||
|
}
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
await renderToString(
|
await renderToString(
|
||||||
createApp({
|
createApp({
|
||||||
components: {
|
components: {
|
||||||
one: {
|
one: ReusableTransition,
|
||||||
template: `<transition><slot/></transition>`,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
template: `<one><div v-if="false">foo</div></one>`,
|
template: `<one><div v-if="false">foo</div></one>`,
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
).toBe(`<!---->`)
|
).toBe(`<!---->`)
|
||||||
|
|
||||||
|
expect(await renderToString(createApp(ReusableTransition))).toBe(`<!---->`)
|
||||||
|
|
||||||
|
expect(await renderToString(createApp(ReusableTransitionWithAppear))).toBe(
|
||||||
|
`<template><!----></template>`,
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(
|
||||||
|
await renderToString(
|
||||||
|
createApp({
|
||||||
|
components: {
|
||||||
|
one: ReusableTransition,
|
||||||
|
},
|
||||||
|
template: `<one><slot/></one>`,
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
).toBe(`<!---->`)
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
await renderToString(
|
await renderToString(
|
||||||
createApp({
|
createApp({
|
||||||
components: {
|
components: {
|
||||||
one: {
|
one: ReusableTransitionWithAppear,
|
||||||
template: `<transition><slot/></transition>`,
|
|
||||||
},
|
},
|
||||||
|
template: `<one><slot/></one>`,
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
).toBe(`<template><!----></template>`)
|
||||||
|
|
||||||
|
expect(
|
||||||
|
await renderToString(
|
||||||
|
createApp({
|
||||||
|
render() {
|
||||||
|
return h(ReusableTransition, null, {
|
||||||
|
default: () => null,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
).toBe(`<!---->`)
|
||||||
|
|
||||||
|
expect(
|
||||||
|
await renderToString(
|
||||||
|
createApp({
|
||||||
|
render() {
|
||||||
|
return h(ReusableTransitionWithAppear, null, {
|
||||||
|
default: () => null,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
).toBe(`<template><!----></template>`)
|
||||||
|
|
||||||
|
expect(
|
||||||
|
await renderToString(
|
||||||
|
createApp({
|
||||||
|
render() {
|
||||||
|
return h(ReusableTransitionWithAppear, null, {
|
||||||
|
default: () => [],
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
).toBe(`<template><!----></template>`)
|
||||||
|
|
||||||
|
expect(
|
||||||
|
await renderToString(
|
||||||
|
createApp({
|
||||||
|
render() {
|
||||||
|
return h(ReusableTransition, null, {
|
||||||
|
default: () => [],
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
).toBe(`<!---->`)
|
||||||
|
|
||||||
|
expect(
|
||||||
|
await renderToString(
|
||||||
|
createApp({
|
||||||
|
components: {
|
||||||
|
one: ReusableTransition,
|
||||||
},
|
},
|
||||||
template: `<one><div v-if="true">foo</div></one>`,
|
template: `<one><div v-if="true">foo</div></one>`,
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -74,6 +74,8 @@ export function ssrRenderSlotInner(
|
||||||
)
|
)
|
||||||
} else if (fallbackRenderFn) {
|
} else if (fallbackRenderFn) {
|
||||||
fallbackRenderFn()
|
fallbackRenderFn()
|
||||||
|
} else if (transition) {
|
||||||
|
push(`<!---->`)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// ssr slot.
|
// ssr slot.
|
||||||
|
@ -110,13 +112,19 @@ export function ssrRenderSlotInner(
|
||||||
end--
|
end--
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (start < end) {
|
||||||
for (let i = start; i < end; i++) {
|
for (let i = start; i < end; i++) {
|
||||||
push(slotBuffer[i])
|
push(slotBuffer[i])
|
||||||
}
|
}
|
||||||
|
} else if (transition) {
|
||||||
|
push(`<!---->`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (fallbackRenderFn) {
|
} else if (fallbackRenderFn) {
|
||||||
fallbackRenderFn()
|
fallbackRenderFn()
|
||||||
|
} else if (transition) {
|
||||||
|
push(`<!---->`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue