]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
test: add tests for SVG/MATH tags without explicit root edison/feat/svgAndMathML 13703/head
authordaiwei <daiwei521@126.com>
Sun, 3 Aug 2025 02:51:22 +0000 (10:51 +0800)
committerdaiwei <daiwei521@126.com>
Sun, 3 Aug 2025 02:51:22 +0000 (10:51 +0800)
svg/math tags might be the root of a component

packages/compiler-dom/__tests__/parse.spec.ts

index 6bcbfd8492e8a64d9091419fa723da4d60594caa..e02b8c7b87ab6c61674bf2cc3ca70586153923e2 100644 (file)
@@ -491,6 +491,17 @@ describe('DOM parser', () => {
       expect(element.ns).toBe(Namespaces.SVG)
     })
 
+    test('SVG tags without explicit root', () => {
+      const ast = parse('<text/><view/><tspan/>', parserOptions)
+      const textNode = ast.children[0] as ElementNode
+      const viewNode = ast.children[1] as ElementNode
+      const tspanNode = ast.children[2] as ElementNode
+
+      expect(textNode.ns).toBe(Namespaces.SVG)
+      expect(viewNode.ns).toBe(Namespaces.SVG)
+      expect(tspanNode.ns).toBe(Namespaces.SVG)
+    })
+
     test('MATH in HTML namespace', () => {
       const ast = parse('<html><math></math></html>', parserOptions)
       const elementHtml = ast.children[0] as ElementNode
@@ -500,6 +511,17 @@ describe('DOM parser', () => {
       expect(element.ns).toBe(Namespaces.MATH_ML)
     })
 
+    test('MATH tags without explicit root', () => {
+      const ast = parse('<mi/><mn/><mo/>', parserOptions)
+      const miNode = ast.children[0] as ElementNode
+      const mnNode = ast.children[1] as ElementNode
+      const moNode = ast.children[2] as ElementNode
+
+      expect(miNode.ns).toBe(Namespaces.MATH_ML)
+      expect(mnNode.ns).toBe(Namespaces.MATH_ML)
+      expect(moNode.ns).toBe(Namespaces.MATH_ML)
+    })
+
     test('root ns', () => {
       const ast = parse('<foreignObject><test/></foreignObject>', {
         ...parserOptions,