]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix: use Namespace type for namespace handling
authordaiwei <daiwei521@126.com>
Sun, 3 Aug 2025 02:33:39 +0000 (10:33 +0800)
committerdaiwei <daiwei521@126.com>
Sun, 3 Aug 2025 02:33:39 +0000 (10:33 +0800)
packages/compiler-vapor/src/ir/index.ts
packages/runtime-vapor/src/dom/template.ts

index b7c67eac9233b6511bee335f8e78cf44c0c1d336..fd4eefd559bd62c127c49227145f5f5e485ba878 100644 (file)
@@ -5,7 +5,7 @@ import type {
   SimpleExpressionNode,
   TemplateChildNode,
 } from '@vue/compiler-dom'
-import type { Prettify } from '@vue/shared'
+import type { Namespace, Prettify } from '@vue/shared'
 import type { DirectiveTransform, NodeTransform } from '../transform'
 import type { IRProp, IRProps, IRSlots } from './component'
 
@@ -59,7 +59,7 @@ export interface RootIRNode {
   type: IRNodeTypes.ROOT
   node: RootNode
   source: string
-  template: Map<string, number>
+  template: Map<string, Namespace>
   templateIndexMap: Map<string, number>
   rootTemplateIndex?: number
   component: Set<string>
index 684626a1aabad41b0bdf0ca338a0aedb9e7cdb49..66b9ea7d2de0804ed02ff33917133c4d5402487f 100644 (file)
@@ -1,13 +1,14 @@
 import { mathmlNS, svgNS } from '@vue/runtime-dom'
 import { adoptTemplate, currentHydrationNode, isHydrating } from './hydration'
 import { child, createTextNode } from './node'
+import { type Namespace, Namespaces } from '@vue/shared'
 
 let t: HTMLTemplateElement
 let st: HTMLTemplateElement
 let mt: HTMLTemplateElement
 
 /*! #__NO_SIDE_EFFECTS__ */
-export function template(html: string, root?: boolean, ns?: number) {
+export function template(html: string, root?: boolean, ns?: Namespace) {
   let node: Node
   return (): Node & { $root?: true } => {
     if (isHydrating) {
@@ -26,7 +27,7 @@ export function template(html: string, root?: boolean, ns?: number) {
         t = t || document.createElement('template')
         t.innerHTML = html
         node = child(t.content)
-      } else if (ns === 1) {
+      } else if (ns === Namespaces.SVG) {
         st = st || document.createElementNS(svgNS, 'template')
         st.innerHTML = html
         node = child(st)