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

Generating <image /> elements inside an <svg> ends up with <img /> outside #1063

Closed
1 task
n-gt opened this issue Jan 27, 2025 · 3 comments · Fixed by #1062
Closed
1 task

Generating <image /> elements inside an <svg> ends up with <img /> outside #1063

n-gt opened this issue Jan 27, 2025 · 3 comments · Fixed by #1062
Labels
- P3: minor bug An edge case that only affects very specific usage (priority)

Comments

@n-gt
Copy link

n-gt commented Jan 27, 2025

Astro Info

Astro                    v5.1.8
Node                     v20.15.1
System                   Linux (x64)
Package Manager          npm
Output                   server
Adapter                  @astrojs/cloudflare
Integrations             astro-icon
                         @astrojs/tailwind
                         @astrojs/alpinejs

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

When I try to add elements to an SVG programmatically within an <svg></svg>, the resulting html ends up with <img> tags outside of it.

What's the expected result?

<svg>
  <image 1.. />
  <image 2.. />
  ....
</svg>

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-hx1emndl?file=src%2Fpages%2Findex.astro

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Jan 27, 2025
@Trombach
Copy link
Contributor

I believe this is a compiler issue. The TS transform incorrectly replaces the image tags with img.

@Trombach
Copy link
Contributor

Trombach commented Feb 2, 2025

This was actually an issue with using an expression {} inside an SVG element. This minimal example produces the wrong output, but just removing the curly braces fixes it.
I've submitted a PR in the compiler repo to fix this. This issue should probably be moved there as well.

@ascorbic ascorbic transferred this issue from withastro/astro Feb 4, 2025
@ascorbic ascorbic added - P3: minor bug An edge case that only affects very specific usage (priority) and removed needs triage Issue needs to be triaged labels Feb 4, 2025
@n-gt
Copy link
Author

n-gt commented Feb 4, 2025

Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P3: minor bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants