Skip to content

Commit 6754842

Browse files
committed
test: add test
1 parent 26a579b commit 6754842

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,6 +1654,29 @@ describe('SSR hydration', () => {
16541654
expect(`mismatch`).not.toHaveBeenWarned()
16551655
})
16561656

1657+
test('transition appear work with pre-existing class', () => {
1658+
const { vnode, container } = mountWithHydration(
1659+
`<template><div class="foo">foo</div></template>`,
1660+
() =>
1661+
h(
1662+
Transition,
1663+
{ appear: true },
1664+
{
1665+
default: () => h('div', { class: 'foo' }, 'foo'),
1666+
},
1667+
),
1668+
)
1669+
expect(container.firstChild).toMatchInlineSnapshot(`
1670+
<div
1671+
class="foo v-enter-from v-enter-active"
1672+
>
1673+
foo
1674+
</div>
1675+
`)
1676+
expect(vnode.el).toBe(container.firstChild)
1677+
expect(`mismatch`).not.toHaveBeenWarned()
1678+
})
1679+
16571680
test('transition appear with v-if', () => {
16581681
const show = false
16591682
const { vnode, container } = mountWithHydration(

packages/runtime-core/src/hydration.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,12 @@ function propHasMismatch(
800800
if (key === 'class') {
801801
// classes might be in different order, but that doesn't affect cascade
802802
// so we just need to check if the class lists contain the same classes.
803-
actual = el.$cls || el.getAttribute('class')
803+
if (el.$cls) {
804+
actual = el.$cls
805+
delete el.$cls
806+
} else {
807+
actual = el.getAttribute('class')
808+
}
804809
expected = normalizeClass(clientValue)
805810
if (!isSetEqual(toClassSet(actual || ''), toClassSet(expected))) {
806811
mismatchType = MismatchTypes.CLASS

0 commit comments

Comments
 (0)