From: daiwei Date: Sun, 3 Aug 2025 02:51:22 +0000 (+0800) Subject: test: add tests for SVG/MATH tags without explicit root X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fheads%2Fedison%2Ffeat%2FsvgAndMathML;p=thirdparty%2Fvuejs%2Fcore.git test: add tests for SVG/MATH tags without explicit root svg/math tags might be the root of a component --- diff --git a/packages/compiler-dom/__tests__/parse.spec.ts b/packages/compiler-dom/__tests__/parse.spec.ts index 6bcbfd849..e02b8c7b8 100644 --- a/packages/compiler-dom/__tests__/parse.spec.ts +++ b/packages/compiler-dom/__tests__/parse.spec.ts @@ -491,6 +491,17 @@ describe('DOM parser', () => { expect(element.ns).toBe(Namespaces.SVG) }) + test('SVG tags without explicit root', () => { + const ast = parse('', 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('', 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('', 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('', { ...parserOptions,