Skip to content

Commit

Permalink
fix(hydration): handle camel-case tag name when performing match asse…
Browse files Browse the repository at this point in the history
…rtion (#3247)

fix #3243
  • Loading branch information
HcySunYang authored Mar 26, 2021
1 parent 420c8f4 commit 9036f88
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions packages/runtime-core/__tests__/hydration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,15 @@ describe('SSR hydration', () => {
expect(spy).toHaveBeenCalled()
})

test('elements with camel-case in svg ', () => {
const { vnode, container } = mountWithHydration(
'<animateTransform></animateTransform>',
() => h('animateTransform')
)
expect(vnode.el).toBe(container.firstChild)
expect(`Hydration node mismatch`).not.toHaveBeenWarned()
})

test('SVG as a mount container', () => {
const svgContainer = document.createElement('svg')
svgContainer.innerHTML = '<g></g>'
Expand Down
3 changes: 2 additions & 1 deletion packages/runtime-core/src/hydration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ export function createHydrationFunctions(
if (shapeFlag & ShapeFlags.ELEMENT) {
if (
domType !== DOMNodeTypes.ELEMENT ||
vnode.type !== (node as Element).tagName.toLowerCase()
(vnode.type as string).toLowerCase() !==
(node as Element).tagName.toLowerCase()
) {
nextNode = onMismatch()
} else {
Expand Down

0 comments on commit 9036f88

Please sign in to comment.