Skip to content

Commit

Permalink
test: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
edison1105 committed May 27, 2021
1 parent 0f882ee commit 912bd0e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
40 changes: 40 additions & 0 deletions packages/runtime-core/__tests__/rendererOptimizedMode.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
h,
Fragment,
Suspense,
Teleport,
createVNode,
createCommentVNode,
Expand Down Expand Up @@ -784,4 +785,43 @@ describe('renderer: optimized mode', () => {
await nextTick()
expect(inner(root)).toBe('<div><div><span>loading</span></div></div>')
})

// #3828
test('patch suspense exit optimized mode', async () => {
const show = ref(false)

const app = createApp({
setup() {
return () => {
return (
openBlock(),
createBlock(
Fragment,
null,
[
(openBlock(),
createBlock(Suspense as any, null, {
default: withCtx(() => [
createVNode('div', null, [
createTextVNode(show.value as any, PatchFlags.TEXT)
])
]),
_: SlotFlags.STABLE
})),
createVNode('div', null, show.value, PatchFlags.TEXT)
],
PatchFlags.STABLE_FRAGMENT
)
)
}
}
})

app.mount(root)
expect(inner(root)).toBe('<div>false</div><div>false</div>')

show.value = true
await nextTick()
expect(inner(root)).toBe('<div>true</div><div>true</div>')
})
})
8 changes: 4 additions & 4 deletions packages/runtime-core/src/components/Suspense.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ function patchSuspense(
suspense,
isSVG,
slotScopeIds,
optimized
!!newBranch.dynamicChildren
)
if (suspense.deps <= 0) {
suspense.resolve()
Expand All @@ -196,7 +196,7 @@ function patchSuspense(
null, // fallback tree will not have suspense context
isSVG,
slotScopeIds,
optimized
!!newBranch.dynamicChildren
)
setActiveBranch(suspense, newFallback)
}
Expand Down Expand Up @@ -245,7 +245,7 @@ function patchSuspense(
null, // fallback tree will not have suspense context
isSVG,
slotScopeIds,
optimized
!!newBranch.dynamicChildren
)
setActiveBranch(suspense, newFallback)
}
Expand All @@ -260,7 +260,7 @@ function patchSuspense(
suspense,
isSVG,
slotScopeIds,
optimized
!!newBranch.dynamicChildren
)
// force resolve
suspense.resolve(true)
Expand Down

0 comments on commit 912bd0e

Please sign in to comment.