Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MathML is unsupported #55608

Closed
lukewarlow opened this issue May 1, 2024 · 10 comments
Closed

MathML is unsupported #55608

lukewarlow opened this issue May 1, 2024 · 10 comments
Labels
area: compiler Issues related to `ngc`, Angular's template compiler compiler: template type-checking state: has PR
Milestone

Comments

@lukewarlow
Copy link

lukewarlow commented May 1, 2024

Which @angular/* package(s) are the source of the bug?

core

Is this a regression?

No

Description

When trying to use MathML in an angular template you get a warning that <math> it's an unrecognised element. If you disable this warning by adding schemas: [NO_ERRORS_SCHEMA] it doesn't render correctly. At first glance they seem correct because the produced elements are in the MathML namespace (something other frameworks can get wrong) but the element's prototype is just Element rather than MathMLElement.

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/github-tdmxzz?file=src%2Fmain.ts

Please provide the exception or error you saw

Error in src/main.ts (12:3)
':math:math' is not a known element:
1. If ':math:math' is an Angular component, then verify that it is included in the '@Component.imports' of this component.
2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@Component.schemas' of this component.


### Please provide the environment you discovered this bug in (run `ng version`)

_No response_

### Anything else?

The template I tried is below. 

```html
<math>
  <mfrac>
    <mn>1</mn>
    <msqrt>
      <mn>2</mn>
    </msqrt>
  </mfrac>
</math>
@JoostK
Copy link
Member

JoostK commented May 1, 2024

Interesting, this should work as we do parse this as math namespace, but then fail to validate it correctly.

@JoostK JoostK added area: compiler Issues related to `ngc`, Angular's template compiler compiler: template type-checking labels May 1, 2024
@ngbot ngbot bot added this to the needsTriage milestone May 1, 2024
@lukewarlow
Copy link
Author

Intersting, this should work as we do parse this as math namespace, but then fail to validate it correctly.

Yeah, there's definitely some level of support for it, the namespace appears correct but then it seems to get the prototype wrong (not even sure how that's possible?). As a guess it's not using createElementNS(), it's doing something else.

@JeanMeche
Copy link
Member

JeanMeche commented May 1, 2024

Yeah the compiler output clearly has the MathML support in it.

The DomRenderer relies on createElementNS() but it looks like the namespace is wrong.

'math': 'http://www.w3.org/1998/MathML/',

It should be http://www.w3.org/1998/Math/MathML per this

JeanMeche added a commit to JeanMeche/angular that referenced this issue May 1, 2024
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).
JeanMeche added a commit to JeanMeche/angular that referenced this issue May 1, 2024
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).
@JeanMeche
Copy link
Member

JeanMeche commented May 1, 2024

With #55622 we'll at least get the support for MathML but it will still require NO_ERRORS_SCHEMA .

JeanMeche added a commit to JeanMeche/angular that referenced this issue May 1, 2024
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).
JeanMeche added a commit to JeanMeche/angular that referenced this issue May 1, 2024
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).
@JoostK
Copy link
Member

JoostK commented May 1, 2024

With #55622 we'll at least get the support for MathML but it will still require NO_ERRORS_SCHEMA .

Yeah that error is because DomSchemaChecker is looking up the definition using the prefixed tagname :math:math which isn't present, as it only contains non-prefixed tagnames.

We should ideally have a branded type for those prefixed tag names, that will likely expose some inconsistencies.

@lukewarlow
Copy link
Author

@JeanMeche great catch! I was just helping someone else with a similar issue where createElementNS was returning an Element and it was an invalid namespace which brought me back here, you're one step ahead though

crisbeto added a commit to crisbeto/angular that referenced this issue May 2, 2024
Fixes that we didn't have the MathML elements in the schema. Note that we can't discover which tag names are available by looking at globally-available classes, because all MathML elements are `MathMLElement` rather than something like `SVGCircleElement`. As such, I ended up having to hardcode the currently-available tags.

Fixes angular#55608.
crisbeto added a commit to crisbeto/angular that referenced this issue May 2, 2024
Fixes that we didn't have the MathML elements in the schema. Note that we can't discover which tag names are available by looking at globally-available classes, because all MathML elements are `MathMLElement` rather than something like `SVGCircleElement`. As such, I ended up having to hardcode the currently-available tags.

Fixes angular#55608.
crisbeto added a commit to crisbeto/angular that referenced this issue May 2, 2024
Fixes that we didn't have the MathML elements in the schema. Note that we can't discover which tag names are available by looking at globally-available classes, because all MathML elements are `MathMLElement` rather than something like `SVGCircleElement`. As such, I ended up having to hardcode the currently-available tags.

Fixes angular#55608.
crisbeto added a commit to crisbeto/angular that referenced this issue May 2, 2024
Fixes that we didn't have the MathML elements in the schema. Note that we can't discover which tag names are available by looking at globally-available classes, because all MathML elements are `MathMLElement` rather than something like `SVGCircleElement`. As such, I ended up having to hardcode the currently-available tags.

Fixes angular#55608.
AndrewKushnir pushed a commit that referenced this issue May 2, 2024
Fixes that we didn't have the MathML elements in the schema. Note that we can't discover which tag names are available by looking at globally-available classes, because all MathML elements are `MathMLElement` rather than something like `SVGCircleElement`. As such, I ended up having to hardcode the currently-available tags.

Fixes #55608.

PR Close #55631
crisbeto added a commit to crisbeto/angular that referenced this issue May 2, 2024
Fixes that we didn't have the MathML elements in the schema. Note that we can't discover which tag names are available by looking at globally-available classes, because all MathML elements are `MathMLElement` rather than something like `SVGCircleElement`. As such, I ended up having to hardcode the currently-available tags.

Fixes angular#55608.

PR Close angular#55631
crisbeto added a commit to crisbeto/angular that referenced this issue May 2, 2024
Fixes that we didn't have the MathML elements in the schema. Note that we can't discover which tag names are available by looking at globally-available classes, because all MathML elements are `MathMLElement` rather than something like `SVGCircleElement`. As such, I ended up having to hardcode the currently-available tags.

Fixes angular#55608.

PR Close angular#55631
crisbeto added a commit to crisbeto/angular that referenced this issue May 2, 2024
Fixes that we didn't have the MathML elements in the schema. Note that we can't discover which tag names are available by looking at globally-available classes, because all MathML elements are `MathMLElement` rather than something like `SVGCircleElement`. As such, I ended up having to hardcode the currently-available tags.

Fixes angular#55608.

PR Close angular#55631
AndrewKushnir pushed a commit that referenced this issue May 2, 2024
Fixes that we didn't have the MathML elements in the schema. Note that we can't discover which tag names are available by looking at globally-available classes, because all MathML elements are `MathMLElement` rather than something like `SVGCircleElement`. As such, I ended up having to hardcode the currently-available tags.

Fixes #55608.

PR Close #55631

PR Close #55645
@lukewarlow
Copy link
Author

Would be good to reopen this issue until #55622 is merged (or go ahead and merge that as it's approved)

@JeanMeche JeanMeche reopened this May 2, 2024
@JeanMeche
Copy link
Member

@lukewarlow Yes, we're looking at landing this "fix" into 17.3 and the upcomming 18.0 !

JeanMeche added a commit to JeanMeche/angular that referenced this issue May 2, 2024
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).
AndrewKushnir pushed a commit that referenced this issue May 3, 2024
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
AndrewKushnir pushed a commit that referenced this issue May 3, 2024
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
@lukewarlow
Copy link
Author

Closing this now that the second PR has been merged.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jun 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: compiler Issues related to `ngc`, Angular's template compiler compiler: template type-checking state: has PR
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants