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.
  • Loading branch information
JeanMeche committed May 13, 2024
1 parent 84f70cc commit 95b54e6
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describe('typeahead', () => {

const task: MockTask = {
id: {} as MockTask['id'],
fn: fn.bind<null, unknown, unknown>(null, ...args),
fn: fn.bind(null, ...args),
delay,
recurring,
nextTriggerTime: this.now + delay,
Expand Down
8 changes: 4 additions & 4 deletions aio/tools/examples/shared/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8055,10 +8055,10 @@ typed-assert@^1.0.8:
resolved "https://registry.yarnpkg.com/typed-assert/-/typed-assert-1.0.9.tgz#8af9d4f93432c4970ec717e3006f33f135b06213"
integrity sha512-KNNZtayBCtmnNmbo5mG47p1XsCyrx6iVqomjcZnec/1Y5GGARaxPs6r49RnSPeUP3YjNYiU9sQHAtY4BBvnZwg==

typescript@~4.9.3:
version "4.9.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a"
integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==
typescript@~5.4.0:
version "5.4.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.4.5.tgz#42ccef2c571fdbd0f6718b1d1f5e6e5ef006f611"
integrity sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==

ua-parser-js@^0.7.30:
version "0.7.35"
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/acceptance/view_container_ref_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ describe('ViewContainerRef', () => {
expect(fixture.nativeElement.querySelector('svg').namespaceURI)
.toEqual('http://www.w3.org/2000/svg');
expect(fixture.nativeElement.querySelector('math').namespaceURI)
.toEqual('http://www.w3.org/1998/MathML/');
.toEqual('http://www.w3.org/1998/Math/MathML');
});
}

Expand Down
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 @@ -20,7 +20,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
19 changes: 19 additions & 0 deletions packages/platform-browser/test/dom/dom_renderer_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,25 @@ 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', () => {
// MathMLElement is fairly recent and doesn't exist on our Saucelabs test environments
if (typeof MathMLElement !== 'undefined') {
expect(
document.createElementNS(NAMESPACE_URIS['math'], 'math') instanceof MathMLElement,
)
.toBeTrue();
}
});
});
});


Expand Down

0 comments on commit 95b54e6

Please sign in to comment.