fix(suspense): fix suspense patching in optimized mode

fix #3828
This commit is contained in:
Evan You
2021-05-27 16:32:31 -04:00
parent f0eb1978b2
commit 9f24195d2c
3 changed files with 74 additions and 29 deletions

View File

@@ -23,6 +23,7 @@ import {
createApp
} from '@vue/runtime-test'
import { PatchFlags, SlotFlags } from '@vue/shared'
import { SuspenseImpl } from '../src/components/Suspense'
describe('renderer: optimized mode', () => {
let root: TestElement
@@ -784,4 +785,40 @@ describe('renderer: optimized mode', () => {
await nextTick()
expect(inner(root)).toBe('<div><div><span>loading</span></div></div>')
})
// #3828
test('patch Suspense in optimized mode w/ nested dynamic nodes', async () => {
const show = ref(false)
const app = createApp({
render() {
return (
openBlock(),
createBlock(
Fragment,
null,
[
(openBlock(),
createBlock(SuspenseImpl, null, {
default: withCtx(() => [
createVNode('div', null, [
createVNode('div', null, show.value, PatchFlags.TEXT)
])
]),
_: SlotFlags.STABLE
}))
],
PatchFlags.STABLE_FRAGMENT
)
)
}
})
app.mount(root)
expect(inner(root)).toBe('<div><div>false</div></div>')
show.value = true
await nextTick()
expect(inner(root)).toBe('<div><div>true</div></div>')
})
})