@@ -20327,4 +20327,127 @@ describe('component scope pause across the interop boundary', () => {
2032720327 expect(log).toEqual(['fallback'])
2032820328 expect(host.innerHTML).toContain('<u>1')
2032920329 })
20330+
20331+ test('pausing a vapor parent holds a slot update queued before the pause', async () => {
20332+ const data = ref<any>({ count: 0 })
20333+ const log: string[] = []
20334+ const components: any = { log: (s: string) => void log.push(s) }
20335+ let scope: any
20336+ components.capture = (s: any) => (scope = s)
20337+ components.VdomChild = compile(
20338+ `<script setup>
20339+ import { onBeforeUpdate } from 'vue'
20340+ const components = _components
20341+ onBeforeUpdate(() => components.log('child update'))
20342+ </script>
20343+ <template>
20344+ <div><slot /></div>
20345+ </template>`,
20346+ data,
20347+ components,
20348+ { vapor: false },
20349+ )
20350+ const Parent = compile(
20351+ `<script setup vapor>
20352+ import { getCurrentScope } from 'vue'
20353+ const data = _data
20354+ const components = _components
20355+ components.capture(getCurrentScope())
20356+ </script>
20357+ <template>
20358+ <components.VdomChild>
20359+ <span>{{ data.count }}</span>
20360+ </components.VdomChild>
20361+ </template>`,
20362+ data,
20363+ components,
20364+ )
20365+ const { html } = define(Parent).render()
20366+
20367+ data.value.count++
20368+ scope.pause()
20369+ await nextTick()
20370+ expect(log).toEqual([])
20371+ expect(html()).toBe('<div><span>0</span></div>')
20372+
20373+ scope.resume()
20374+ await nextTick()
20375+ expect(html()).toBe('<div><span>1</span></div>')
20376+ expect(log).toEqual(['child update'])
20377+ })
20378+
20379+ test('pausing a vapor parent pauses the props of a resolved async vdom child', async () => {
20380+ const data = ref<any>({ count: 0 })
20381+ const components: any = {}
20382+ let scope: any
20383+ components.capture = (s: any) => (scope = s)
20384+ const VdomChild = compile(
20385+ `<script setup>
20386+ defineProps(['n'])
20387+ </script>
20388+ <template>
20389+ <span>{{ n }}</span>
20390+ </template>`,
20391+ data,
20392+ {},
20393+ { vapor: false },
20394+ )
20395+ components.Child = defineAsyncComponent(() => Promise.resolve(VdomChild))
20396+ const Parent = compile(
20397+ `<script setup vapor>
20398+ import { getCurrentScope } from 'vue'
20399+ const data = _data
20400+ const components = _components
20401+ components.capture(getCurrentScope())
20402+ </script>
20403+ <template>
20404+ <components.Child :n="data.count" />
20405+ </template>`,
20406+ data,
20407+ components,
20408+ )
20409+ const { html } = define(Parent).render()
20410+ await new Promise(r => setTimeout(r))
20411+ await nextTick()
20412+ expect(html()).toContain('<span>0</span>')
20413+
20414+ scope.pause()
20415+ data.value.count++
20416+ await nextTick()
20417+ expect(html()).toContain('<span>0</span>')
20418+
20419+ scope.resume()
20420+ await nextTick()
20421+ expect(html()).toContain('<span>1</span>')
20422+ })
20423+
20424+ test('pausing a vapor parent pauses the props it adds to a vnode it renders', async () => {
20425+ const data = ref<any>({ count: 0 })
20426+ const components: any = { vnode: h('b', 'x') }
20427+ let scope: any
20428+ components.capture = (s: any) => (scope = s)
20429+ const Parent = compile(
20430+ `<script setup vapor>
20431+ import { getCurrentScope } from 'vue'
20432+ const data = _data
20433+ const components = _components
20434+ components.capture(getCurrentScope())
20435+ </script>
20436+ <template>
20437+ <div><component :is="components.vnode" :title="data.count" /></div>
20438+ </template>`,
20439+ data,
20440+ components,
20441+ )
20442+ const { html } = define(Parent).render()
20443+
20444+ scope.pause()
20445+ data.value.count++
20446+ await nextTick()
20447+ expect(html()).toContain('title="0"')
20448+
20449+ scope.resume()
20450+ await nextTick()
20451+ expect(html()).toContain('title="1"')
20452+ })
2033020453})
0 commit comments