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

Singult doesn't recognize svg <animate> element #22

Open
valyagolev opened this issue Jan 13, 2014 · 4 comments
Open

Singult doesn't recognize svg <animate> element #22

valyagolev opened this issue Jan 13, 2014 · 4 comments

Comments

@valyagolev
Copy link

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!

@lynaghk
Copy link
Owner

lynaghk commented Jan 17, 2014

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.

@valyagolev
Copy link
Author

Okay, thanks!

As this is probably not limited to animate, I was thinking about more general ways to solve the problem, e.g.:

  1. Exposing re_svg_tags to allow changing it from the user code, maybe as a mutable list, or with api
  2. Making inner elements influence the outer elements' namespace, e.g. everything inside <svg> is from its namespace
  3. Allowing namespaced tag names: [:svg:svg [:svg:animate ...]]
  4. 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.

@lynaghk
Copy link
Owner

lynaghk commented Jan 20, 2014

  1. is the wrong solution (users shouldn't have to care)
  2. sounds too complex and magical to implement
  3. namespaced tags are already supported, so this option already exists; however, I think re_svg_tags should just cover all of the known SVG tags so that users don't have to think about it.
  4. 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?

@valyagolev
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants