Skip to content

Commit e533110

Browse files
JeanMecheAndrewKushnir
authored andcommitted
fix(platform-browser): Use the right namespace for mathML. (#55622)
Prior to this change, MathML element were created with the wrong namespace resulting in regular DOM `Element`. This commit fixes this. Related to #55608 (but doesn't fix it entirely). PR Close #55622
1 parent 3a930a5 commit e533110

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

packages/core/test/acceptance/view_container_ref_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ describe('ViewContainerRef', () => {
259259
'http://www.w3.org/2000/svg',
260260
);
261261
expect(fixture.nativeElement.querySelector('math').namespaceURI).toEqual(
262-
'http://www.w3.org/1998/MathML/',
262+
'http://www.w3.org/1998/Math/MathML',
263263
);
264264
});
265265
}

packages/platform-browser/src/dom/dom_renderer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const NAMESPACE_URIS: {[ns: string]: string} = {
3535
'xlink': 'http://www.w3.org/1999/xlink',
3636
'xml': 'http://www.w3.org/XML/1998/namespace',
3737
'xmlns': 'http://www.w3.org/2000/xmlns/',
38-
'math': 'http://www.w3.org/1998/MathML/',
38+
'math': 'http://www.w3.org/1998/Math/MathML',
3939
};
4040

4141
const COMPONENT_REGEX = /%COMP%/g;

packages/platform-browser/test/dom/dom_renderer_spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,23 @@ describe('DefaultDomRendererV2', () => {
252252
expect(await styleCount(fixture, '.emulated')).toBe(0);
253253
});
254254
});
255+
256+
describe('should support namespaces', () => {
257+
it('should create SVG elements', () => {
258+
expect(
259+
document.createElementNS(NAMESPACE_URIS['svg'], 'math') instanceof SVGElement,
260+
).toBeTrue();
261+
});
262+
263+
it('should create MathML elements', () => {
264+
// MathMLElement is fairly recent and doesn't exist on our Saucelabs test environments
265+
if (typeof MathMLElement !== 'undefined') {
266+
expect(
267+
document.createElementNS(NAMESPACE_URIS['math'], 'math') instanceof MathMLElement,
268+
).toBeTrue();
269+
}
270+
});
271+
});
255272
});
256273

257274
async function styleCount(

0 commit comments

Comments
 (0)