mikado icon indicating copy to clipboard operation
mikado copied to clipboard

An issue with applying a `linearGradient` on SVG element.

Open dominikkrulak opened this issue 4 months ago • 0 comments

I have this simple SVG element with a gradient.

<svg viewBox="0 0 10 10">
	<defs>
		<linearGradient id="myGradient" gradientTransform="rotate(90)">
			<stop offset="5%" stop-color="gold" />
			<stop offset="95%" stop-color="red" />
		</linearGradient>
	</defs>
	<circle cx="5" cy="5" r="4" fill="url('#myGradient')" />
</svg>

When rendered, the svg element itself gets rendered but the gradient isn't applied.

Gradient isn't applied example

Screenshot 2024-10-02 at 20 41 17

When I edit the element straight from browser, the gradient is applied after render engine updates DOM.

Gradient is applied after changes made to the element using inspection tool example

Screenshot 2024-10-02 at 20 46 45

When I checked the compiled template

 // ...
  attr: {
	"cx": "5",
	"cy": "5",
	"r": "4",
	"fill": "url('#myGradient')"
 },
// ...

the fill key has #myGradient in quotes. Could this be a problem, maybe?

I created the SVG using vanilla JS and tested it with and without the quotes and it worked in my environment.

Any thought?

dominikkrulak avatar Oct 02 '24 19:10 dominikkrulak