Skip to content

MathML is unsupported #55608

Closed
Closed

Description

@lukewarlow

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>

Activity

  1. JoostK commented on May 1, 2024

    @JoostK
    Member

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

  2. added
    area: compiler
    on May 1, 2024
  3. added this to the needsTriage milestone on May 1, 2024
  4. lukewarlow commented on May 1, 2024

    @lukewarlow
    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.

  5. JeanMeche commented on May 1, 2024

    @JeanMeche
    Member

    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

  6. JeanMeche commented on May 1, 2024

    @JeanMeche
    Member

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

  7. JoostK commented on May 1, 2024

    @JoostK
    Member

    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.

  8. lukewarlow commented on May 1, 2024

    @lukewarlow
    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

  9. 5 remaining items

  10. added a commit that references this issue on May 2, 2024
    2e891ad
  11. added a commit that references this issue on May 2, 2024
    c21b459
  12. lukewarlow commented on May 2, 2024

    @lukewarlow
    Author

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

  13. JeanMeche commented on May 2, 2024

    @JeanMeche
    Member

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

  14. lukewarlow commented on May 3, 2024

    @lukewarlow
    Author

    Closing this now that the second PR has been merged.

  15. angular-automatic-lock-bot commented on Jun 3, 2024

    @angular-automatic-lock-bot

    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.

  16. locked and limited conversation to collaborators on Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: compilercompiler: template type-checkingstate: has PR

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions