Skip to content

Commit

Permalink
fix(platform-browser): Use the right namespace for mathML.
Browse files Browse the repository at this point in the history
Prior to this change, MathML element were created with the wrong namespace resulting in regular DOM `Element`.

This commit fixes this.

Related to angular#55608 (but doesn't fix it entirely).
  • Loading branch information
JeanMeche committed May 1, 2024
1 parent b9a997c commit fbde29d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/platform-browser/src/dom/dom_renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const NAMESPACE_URIS: {[ns: string]: string} = {
'xlink': 'http://www.w3.org/1999/xlink',
'xml': 'http://www.w3.org/XML/1998/namespace',
'xmlns': 'http://www.w3.org/2000/xmlns/',
'math': 'http://www.w3.org/1998/MathML/',
'math': 'http://www.w3.org/1998/Math/MathML',
};

const COMPONENT_REGEX = /%COMP%/g;
Expand Down
14 changes: 14 additions & 0 deletions packages/platform-browser/test/dom/dom_renderer_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,20 @@ describe('DefaultDomRendererV2', () => {
expect(await styleCount(fixture, '.emulated')).toBe(0);
});
});

describe('should support namespaces', () => {
it('should create SVG elements', () => {
expect(
document.createElementNS(NAMESPACE_URIS['svg'], 'math') instanceof SVGElement,
).toBeTrue();
});

it('should create MathML elements', () => {
expect(
document.createElementNS(NAMESPACE_URIS['math'], 'math') instanceof MathMLElement,
).toBeTrue();
});
});
});

async function styleCount(
Expand Down

0 comments on commit fbde29d

Please sign in to comment.