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

Vue doesn't support rendering MathML #7820

Closed
sto3psl opened this issue Mar 3, 2023 · 3 comments · Fixed by #7836
Closed

Vue doesn't support rendering MathML #7820

sto3psl opened this issue Mar 3, 2023 · 3 comments · Fixed by #7836
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. has PR A pull request has already been submitted to solve the issue ✨ feature request New feature or request

Comments

@sto3psl
Copy link
Contributor

sto3psl commented Mar 3, 2023

Vue version

3.2.27

Link to minimal reproduction

https://sfc.vuejs.org/#eNrlV71u2zAQfhVWixO0lpCikyEL6JYhXoqiXTRUlmiLgUgKJO0MhsdOfcs+SY5SYlvkMbGTDPlZDN4v7+476wM30fe2jdcrGk2iVJeKtYZoalZtlgvGW6kM2RBFF2RLFkpyMgLXUS5yUUqhDeF6SabWfja6pE0jyW+pmurT6DwXadKng0QgGMrbpjAUJELS+iL7QUVFFRNLMitMPbsiN8zU5NeKpglYOy8Ohu5kz6aYN330nax2QidWB6JV6K6FvcbqlLxxdFYrs7M0gV/fwrICLAyN+RyMmQdjzpEYUPllpVxkX8Eihk0lTlegGPSNjEFmU+fSI4Kw2bGsRPo6stDQyGz4Nz8cvP7/+4t4Y1ClfKGKEqnrwkv8QL1eDhx9HF8M2+GYrbRf2KdtL76NL4AAEn5i81hevAXsz/GRtv05s34zK/VxoQ9DZM87CgPhntvCXJiWsqIZE4Kqy5+zqzTp5D09Vmzdp16Pa8ObaR7d3/sHCHd/wYA6B3viTMSfB0aZIcIMbxNOluGVwIgSoUkMEgcQBw63XXdnHnH3p4PtyhFl4UPByBCnQgwChAZxEgzU50RjaKLfJA+twyEO/gAnbh7+VXzGbL3AE1r082EFY+T4/nb0aXN8pWvx3mHEx35ARjsqAtKwTj2LJJ3l4NEWfYn65+CYF218raWAB+PGuuZ3Bp1HE9JprA6eiVbOo9qYVk+SRC9K+8y81rFUywROsVoJwziNqebjOXzcNVWQuL9/m4tttL0FFv2m3Q==

Steps to reproduce

  1. Try rendering any MathML tags.

What is expected?

Vue will properly render MathML like it does with HTML and SVG.

What is actually happening?

Vue ignores MathML and thinks the tags are wrongly configured custom elements.

System Info

System:
    OS: macOS 13.2.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.14.0
    npm: 9.3.1
  Browsers:
    Firefox: 110.0
    Firefox Developer Edition: 111.0
    Safari: 16.3
    Safari Technology Preview: 16.4

Any additional comments?

MathML is well supported in all browser engines since Chrome 109 (CanIUse MathML) and tremendously useful for any web pages that want to render mathematical formulas.

MathML support table from CanIUse

A quick test showed that React does support MathML and Svelte does not.

Prior issues:

@LinusBorg
Copy link
Member

LinusBorg commented Mar 3, 2023

There's two layers to this:

  1. Vue needs to add these new tags to the list of known elements, now that they have become supported amongst all major browsers.
  2. Even without 1. though, I would expect for the MathML to properly render as all of the elements seem to be added to the DOM just as you would expect them to (check the devtools elements tab in the provided playground example).

Oh, we need to use the MathML namespace like we use SVG namespace for SVG elements. That will be a bigger change than initially expected.

@LinusBorg LinusBorg added the ✨ feature request New feature or request label Mar 3, 2023
@sto3psl
Copy link
Contributor Author

sto3psl commented Mar 3, 2023

Oh, we need to use the MathML namespace like we use SVG namespace for SVG elements. That will be a bigger change than initially expected.

@LinusBorg This is exactly right. I just checked the code and made it work with MathML.

Working MathML rendered by Vue 3

Obviously I don't have tests yet, but if you want I could open a PR and would be happy to finish the MathML support with some guidance.

Edit: Here is the code if you want to check it out -> main...sto3psl:core:main

@baiwusanyu-c
Copy link
Member

Oh, we need to use the MathML namespace like we use SVG namespace for SVG elements. That will be a bigger change than initially expected.

@LinusBorg This is exactly right. I just checked the code and made it work with MathML.

Working MathML rendered by Vue 3

Obviously I don't have tests yet, but if you want I could open a PR and would be happy to finish the MathML support with some guidance.

Edit: Here is the code if you want to check it out -> main...sto3psl:core:main

I took a quick look and it looks great, I think you can add the test and submit a pr to let everyone see how it goes 👍

@LinusBorg LinusBorg linked a pull request Mar 8, 2023 that will close this issue
@haoqunjiang haoqunjiang added the 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. label Mar 14, 2023
@haoqunjiang haoqunjiang added the has PR A pull request has already been submitted to solve the issue label Aug 31, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jan 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. has PR A pull request has already been submitted to solve the issue ✨ feature request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants