diff --git a/packages/runtime-core/src/hydration.ts b/packages/runtime-core/src/hydration.ts index c7c88eb65de..34d1c392d17 100644 --- a/packages/runtime-core/src/hydration.ts +++ b/packages/runtime-core/src/hydration.ts @@ -33,7 +33,7 @@ const enum DOMNodeTypes { let hasMismatch = false -const isSVGContainer = (container: Element) => +export const isSVGContainer = (container: Element) => /svg/.test(container.namespaceURI!) && container.tagName !== 'foreignObject' const isComment = (node: Node): node is Comment => diff --git a/packages/runtime-core/src/renderer.ts b/packages/runtime-core/src/renderer.ts index da86040d0a1..629e6fb2a9c 100644 --- a/packages/runtime-core/src/renderer.ts +++ b/packages/runtime-core/src/renderer.ts @@ -68,7 +68,11 @@ import { callWithErrorHandling, callWithAsyncErrorHandling } from './errorHandling' -import { createHydrationFunctions, RootHydrateFunction } from './hydration' +import { + createHydrationFunctions, + RootHydrateFunction, + isSVGContainer +} from './hydration' import { invokeDirectiveHook } from './directives' import { startMeasure, endMeasure } from './profiling' import { ComponentPublicInstance } from './componentPublicInstance' @@ -662,7 +666,10 @@ function baseCreateRenderer( isSVG: boolean, optimized: boolean ) => { - isSVG = isSVG || (n2.type as string) === 'svg' + isSVG = + isSVG || + (n2.type as string) === 'svg' || + isSVGContainer(container as Element) if (n1 == null) { mountElement( n2,