Singult doesn't recognize svg <animate> element
Hello,
I may be doing something wrong, but I don't understand what.
I use c2 (and consequently singult) to create an <svg> element, which contains a <path> with <animate> in it. <path> is displayed just fine, however the newly-created <animate> element is not recognised by Chrome as an SVGElement and (consequently?) the animation doesn't happen at all.
I found out that if add the animate into re_svg_tags, like that:
re_svg_tags = /^(animate|svg|g|rect|circle|clipPath|path|line|polygon|polyline|text|textPath)$/;
it works really well.
Do you think it's a singult's issue, or I'm mis-using it somehow?
Thank you!
Nope, you're using it exactly right and even found where you'd need to put the fix. If you want to submit a pull request for this, I'll happily accept it.
Okay, thanks!
As this is probably not limited to animate, I was thinking about more general ways to solve the problem, e.g.:
- Exposing
re_svg_tagsto allow changing it from the user code, maybe as a mutable list, or with api - Making inner elements influence the outer elements' namespace, e.g. everything inside
<svg>is from its namespace - Allowing namespaced tag names:
[:svg:svg [:svg:animate ...]] - Providing a special function/macro to transform the namespace of every inner tag:
(namespaced :svg [:svg [:animate ...]])(probably can be implemented in terms of 3)
I don't like 1, but it seems the simplest. I like 2 a lot, but I'm not sure if it's possible. I like 3 as well. If 3+2 could work that would be great; the next best thing could be 3+4.
What do you think? I'd be happy to work on this problem when I have time.
- is the wrong solution (users shouldn't have to care)
- sounds too complex and magical to implement
- namespaced tags are already supported, so this option already exists; however, I think
re_svg_tagsshould just cover all of the known SVG tags so that users don't have to think about it. - Sounds complicated.
What about just filling out re_svg_tags with everything and then making it clear in the README that svg and html namespace prefixes are already available?
I didn't know namespaced tags are supported, how could I not try, I'll use them for now:)
What about just filling out re_svg_tags with everything and then making it clear in the README that svg and html namespace prefixes are already available?
Well, they're namespaced for a reason, I guess, which is to avoid overlapping. There're some elements which are same in svg and html, e.g. a, script or title (see https://developer.mozilla.org/en-US/docs/Web/SVG/Element ). I'm not sure that's such a big issue, but we'll have to be careful about not accidentally adding the valid html tags there.