Skip to content

Commit b39f88a

Browse files
committed
wip: save
1 parent 114cae7 commit b39f88a

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

packages/runtime-vapor/__tests__/hydration.spec.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4439,6 +4439,7 @@ describe('Vapor Mode hydration', () => {
44394439
expect(container.innerHTML).toBe(
44404440
'<!--[--><!--teleport start--><div>content</div><!--teleport end--><span>tail-updated</span><!--]-->',
44414441
)
4442+
expect('Invalid Teleport target').not.toHaveBeenWarned()
44424443

44434444
data.value.disabled = false
44444445
await nextTick()
@@ -7231,6 +7232,37 @@ describe('VDOM interop', () => {
72317232
)
72327233
})
72337234

7235+
test('hydrate createDynamicComponent to null branch should remove stale branch before trailing sibling', async () => {
7236+
const data = ref({
7237+
show: false,
7238+
msg: 'late',
7239+
tail: 'tail',
7240+
})
7241+
const { container } = await mountWithHydration(
7242+
'<!--[--><div>late</div><!--dynamic-component--><span>tail</span><!--]-->',
7243+
`<script setup>
7244+
const data = _data
7245+
</script>
7246+
<template>
7247+
<component :is="data.show ? 'div' : null">{{ data.msg }}</component>
7248+
<span>{{ data.tail }}</span>
7249+
</template>`,
7250+
data,
7251+
)
7252+
7253+
expect(`Hydration node mismatch`).not.toHaveBeenWarned()
7254+
expect(`Hydration children mismatch`).toHaveBeenWarned()
7255+
expect(container.innerHTML).toBe(
7256+
'<!--[--><!--dynamic-component--><span>tail</span><!--]-->',
7257+
)
7258+
7259+
data.value.tail = 'tail-updated'
7260+
await nextTick()
7261+
expect(container.innerHTML).toBe(
7262+
'<!--[--><!--dynamic-component--><span>tail-updated</span><!--]-->',
7263+
)
7264+
})
7265+
72347266
test('hydrate createDynamicComponent to null branch at end of container', async () => {
72357267
const data = ref({
72367268
show: true,

packages/runtime-vapor/src/dom/prop.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,8 @@ export function setText(el: Text & { $txt?: string }, value: string): void {
346346
return
347347
}
348348

349-
if (!isMismatchAllowed(el.parentElement!, MismatchTypes.TEXT)) {
349+
const parent = el.parentElement
350+
if (parent && !isMismatchAllowed(parent, MismatchTypes.TEXT)) {
350351
;(__DEV__ || __FEATURE_PROD_HYDRATION_MISMATCH_DETAILS__) &&
351352
warn(
352353
`Hydration text mismatch in`,

0 commit comments

Comments
 (0)