Skip to content

Commit 314ce82

Browse files
committed
test: test case for 3d34f40 / #10870
1 parent ee0248a commit 314ce82

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

packages/runtime-core/__tests__/rendererOptimizedMode.spec.ts

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {
88
createApp,
99
createBlock,
1010
createCommentVNode,
11+
createElementBlock,
12+
createElementVNode,
1113
createTextVNode,
1214
createVNode,
1315
defineComponent,
@@ -962,4 +964,80 @@ describe('renderer: optimized mode', () => {
962964
// should successfully unmount without error
963965
expect(inner(root)).toBe(`<!---->`)
964966
})
967+
968+
// #10870
969+
test('should bail manually rendered compiler slots for both mount and update', async () => {
970+
// only reproducible in prod
971+
__DEV__ = false
972+
function Outer(_: any, { slots }: any) {
973+
return slots.default()
974+
}
975+
const Mid = {
976+
render(ctx: any) {
977+
return (
978+
openBlock(),
979+
createElementBlock('div', null, [renderSlot(ctx.$slots, 'default')])
980+
)
981+
},
982+
}
983+
const state1 = ref(true)
984+
const state2 = ref(true)
985+
const App = {
986+
render() {
987+
return (
988+
openBlock(),
989+
createBlock(Outer, null, {
990+
default: withCtx(() => [
991+
createVNode(
992+
Mid,
993+
{ foo: state2.value },
994+
{
995+
default: withCtx(() => [
996+
createElementVNode('div', null, [
997+
createElementVNode('div', null, [
998+
state2.value
999+
? (openBlock(),
1000+
createElementBlock(
1001+
'div',
1002+
{
1003+
key: 0,
1004+
id: 'if',
1005+
foo: state1.value,
1006+
},
1007+
null,
1008+
8 /* PROPS */,
1009+
['foo'],
1010+
))
1011+
: createCommentVNode('v-if', true),
1012+
]),
1013+
]),
1014+
]),
1015+
_: 1 /* STABLE */,
1016+
},
1017+
8 /* PROPS */,
1018+
['foo'],
1019+
),
1020+
]),
1021+
_: 1 /* STABLE */,
1022+
})
1023+
)
1024+
},
1025+
}
1026+
1027+
const app = createApp(App)
1028+
app.config.errorHandler = vi.fn()
1029+
1030+
try {
1031+
app.mount(root)
1032+
1033+
state1.value = false
1034+
await nextTick()
1035+
1036+
state2.value = false
1037+
await nextTick()
1038+
} finally {
1039+
__DEV__ = true
1040+
expect(app.config.errorHandler).not.toHaveBeenCalled()
1041+
}
1042+
})
9651043
})

0 commit comments

Comments
 (0)