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

Elements inside SVG don’t scale #45

Closed
arturi opened this issue Sep 12, 2016 · 3 comments
Closed

Elements inside SVG don’t scale #45

arturi opened this issue Sep 12, 2016 · 3 comments

Comments

@arturi
Copy link

arturi commented Sep 12, 2016

Thank you for your work in bel and yo-yo 👍

Consider this SVG:

<svg width="140" height="140" viewbox="0 0 70 70">
  <circle cx="35" cy="35" r="30" stroke-width="3" fill="red" />
</svg>

The circle should scale up to fill SVG’s, according to its viewbox, but when the element is created with bel, circle doesn’t scale.

Live example: http://requirebin.com/?gist=32979ca8d3231e3a86ac872260fa3322 — the second element is created manually and scales like it should. In DOM they look identical, must be some SVG behind-the-scenes magic?

@shama
Copy link
Member

shama commented Sep 13, 2016

Oh weird, so if you do viewbox="0 0 70 70" in the innerHTML the browser corrects the attribute to viewBox.

But since bel will do element.setAttribute('viewbox', '0 0 70 70') it will not correct the attribute.

The technical answer is use viewBox as that attribute is named with a capital B but I'm curious as to when/why the browser will correct attributes and when it will not, heh.


It looks like all SVG attributes are case sensitive.

@arturi
Copy link
Author

arturi commented Sep 13, 2016

Oh, thanks! Was not aware it’s actually viewBox. Do you think a warning should be added in docs or console?

@shama
Copy link
Member

shama commented Sep 14, 2016

Added to the docs thanks!

@shama shama closed this as completed Sep 14, 2016
arturi added a commit to arturi/babel-plugin-yo-yoify that referenced this issue Feb 27, 2017
Because it’s case-sensitive, and Bel doesn’t correct it, please see https://github.com/shama/bel/wiki#svg and choojs/nanohtml#45
goto-bus-stop pushed a commit to goto-bus-stop/babel-plugin-yo-yoify that referenced this issue Feb 27, 2017
* Don’t convert SVG viewBox attribute to lowercase

Because it’s case-sensitive, and Bel doesn’t correct it, please see https://github.com/shama/bel/wiki#svg and choojs/nanohtml#45

* viewbox --> viewBox

* don’t convert to lowercase, since some attributes are case-sensetive, classname --> className
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