From: daiwei Date: Fri, 25 Jul 2025 09:33:30 +0000 (+0800) Subject: wip: save X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=307baff82d10e3699f94199aa22f6f62bbf44fde;p=thirdparty%2Fvuejs%2Fcore.git wip: save --- diff --git a/packages/runtime-vapor/__tests__/dom/mathML.spec.ts b/packages/runtime-vapor/__tests__/dom/mathML.spec.ts index 148d4c300b..490d0c497d 100644 --- a/packages/runtime-vapor/__tests__/dom/mathML.spec.ts +++ b/packages/runtime-vapor/__tests__/dom/mathML.spec.ts @@ -1 +1,69 @@ -describe.todo('MathML support', () => {}) +import { makeRender } from '../_utils' +import { template } from '../../src/dom/template' +import { child } from '../../src/dom/node' +import { setClass } from '../../src/dom/prop' +import { renderEffect } from '../../src' +import { nextTick, ref } from '@vue/runtime-dom' + +const define = makeRender() + +describe('MathML support', () => { + afterEach(() => { + document.body.innerHTML = '' + }) + + test('should mount elements with correct html namespace', () => { + define({ + setup() { + const t0 = template( + 'x2+y
', + true, + 2, + ) + const n0 = t0() + return n0 + }, + }).render() + + const e0 = document.getElementById('e0')! + expect(e0.namespaceURI).toMatch('Math') + expect(e0.querySelector('#e1')!.namespaceURI).toMatch('Math') + expect(e0.querySelector('#e2')!.namespaceURI).toMatch('Math') + expect(e0.querySelector('#e3')!.namespaceURI).toMatch('Math') + expect(e0.querySelector('#e4')!.namespaceURI).toMatch('xhtml') + expect(e0.querySelector('#e5')!.namespaceURI).toMatch('svg') + }) + + test.todo('should patch elements with correct namespaces', async () => { + const cls = ref('foo') + define({ + setup() { + const t0 = template( + '
', + true, + ) + const n2 = t0() as HTMLElement + const n1 = child(n2) as HTMLElement + const p0 = child(n1) as HTMLElement + const n0 = child(p0) as HTMLElement + renderEffect(() => { + const _cls = cls + setClass(n1, _cls) + // problem is n0 is undefined here + setClass(n0, _cls) + }) + return n2 + }, + }).render() + + const f1 = document.querySelector('#f1')! + const f2 = document.querySelector('#f2')! + expect(f1.getAttribute('class')).toBe('foo') + expect(f2.className).toBe('foo') + + cls.value = 'bar' + await nextTick() + expect(f1.getAttribute('class')).toBe('bar') + expect(f2.className).toBe('bar') + }) +})