Closed bluenote10 closed 4 years ago
Style always overwrites attributes. This is also true in html. However, you can just call style('fill',
null)
to remove the style from the element or remove the style attribute alltogether with attr('style', 'null')
Thanks for the clarification -- I guess it makes sense not to check against style every time when setting an attribute and the work-around should be fine.
This is a really important clarification - I'm finding that any property of the an element set in the "style" attribute of an SVG element tag will take precedence over attributes attempting to be set by the .attr() function. I must remove those specifications from the SVG tag either by javascript, or just removing them by hand, then set them with .attr()
Bug report
Fiddle
Issue arises in a non-fiddle use case, reproducible in a self-contained
.svg
instead.Explanation
I'm trying to animate SVGs generated by Inkscape by embedding svg.js code into the
.svg
file. A minimal example would be:This setup works in general, resulting in an animated svg. What doesn't work is animating the
fill
though. This seems to be caused by thefill: none
style, which Inkscape generates automatically on objects without fill. Removing the style generated by Inkscape manually makes the example fully functional. But shouldn't thefill
call overwrite the style set initially? Can this work in general without manual adaptations to the styles from Inkscape?