<script>
const rootMargin = location.search.match(/rootMargin=(\d+)/)?.[1] ?? 0
const isFragment = location.search.includes('?fragment')
+ const isVIf = location.search.includes('?v-if')
if (isFragment) {
document.getElementById('app').innerHTML =
`<!--[--><!--[--><span>one</span><!--]--><button>0</button><span>two</span><!--]-->`
+ } else if (isVIf) {
+ document.getElementById('app').innerHTML = `<!---->`
}
window.isHydrated = false
ref,
onMounted,
hydrateOnVisible,
+ createCommentVNode,
} = Vue
const Comp = {
{ onClick: () => count.value++ },
count.value,
)
- if (isFragment) {
+ if (isVIf) {
+ return createCommentVNode('v-if', true)
+ } else if (isFragment) {
return [[h('span', 'one')], button, h('span', 'two')]
} else {
return button
await assertHydrationSuccess()
})
+ test('visible (root v-if) should not throw error', async () => {
+ const spy = vi.fn()
+ const currentPage = page()
+ currentPage.on('pageerror', spy)
+ await goToCase('visible', '?v-if')
+ await page().waitForFunction(() => window.isRootMounted)
+ expect(await page().evaluate(() => window.isHydrated)).toBe(false)
+ expect(spy).toBeCalledTimes(0)
+ currentPage.off('pageerror', spy)
+ })
+
test('media query', async () => {
await goToCase('media')
await page().waitForFunction(() => window.isRootMounted)