Skip to content

Svelte 5 removes href of use tag in SVG, breaking sprites #14356

@Razunter

Description

@Razunter

Describe the bug

Svelte 5.2.0+ removes xlink:href and href in <use> tag of SVG when it includes imported variable. There are probably other cases than just this svg issue.

Example:

<script>
	import { sprites } from './_generatedVariables.js'
	
	let name = 'world';
</script>

<h1>Hello {name}!
<svg width="13" height="14" aria-hidden="true">
    <use xlink:href="{sprites['svgsprite2']}#done"></use>
  </svg>
</h1>

Svelte generates component without xlink:href.

Reproduction

https://svelte.dev/playground/70b9436a1d01428da9d1561a272e60c9?version=5.2.3

Logs

No response

System Info

System:
    OS: Linux 5.15 Ubuntu 22.04.5 LTS 22.04.5 LTS (Jammy Jellyfish)
    CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700KF
    Memory: 23.36 GB / 31.27 GB
    Container: Yes
    Shell: 5.8.1 - /usr/bin/zsh
  Binaries:
    Node: 22.11.0 - ~/.volta/tools/image/node/22.11.0/bin/node
    npm: 10.9.0 - ~/.volta/tools/image/node/22.11.0/bin/npm
    pnpm: 9.12.2 - ~/.volta/bin/pnpm
    bun: 1.1.34 - ~/.bun/bin/bun
  npmPackages:
    rollup: ^4.27.3 => 4.27.3
    svelte: 5.2.3 => 5.2.3

Severity

blocking an upgrade

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions