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

SVG and MathML elements not created with the correct namespace, so not rendered. #107

Open
axyl opened this issue Sep 9, 2024 · 0 comments

Comments

@axyl
Copy link

axyl commented Sep 9, 2024

Since createElement is used rather than createElementNS with the right namespace, no SVG elements are rendered. Presumably, MathML has the same issue.

Simple example:

<div id="chart"></div>
<script type="module">
  import { reactive, html } from "https://esm.sh/@arrow-js/core";

  const data = reactive({ values: [10, 20, 30] });

  const svg = html`<svg width="100" height="100" viewBox="0 0 100 100">
    ${data.values.map(
      (v, i) =>
        html`<rect
          x="${i * 10}"
          y="${100 - v}"
          width="9"
          height="${v}"
          fill="red"
        ></rect>`,
    )}
  </svg>`;

  svg(document.getElementById("chart"));
</script>

If you change the parent element, the SVG elements will be processed and rendered...

document.getElementById("chart").innerHTML += "";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant