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

Warn if svg uses the viewbox attribute #1077

Closed
wants to merge 1 commit into from
Closed

Warn if svg uses the viewbox attribute #1077

wants to merge 1 commit into from

Conversation

emilos
Copy link
Contributor

@emilos emilos commented Jan 5, 2018

An attempt to close #1062

The under the hood issue is that:

node.setAttribute('viewbox', '-250 -250 500 500')

does not work while:

node.setAttribute('viewBox', '-250 -250 500 500')

works correctly.

A warning seems to be the simplest solution since that is the right attribute name https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/viewBox

Thanks :)

@codecov-io
Copy link

codecov-io commented Jan 5, 2018

Codecov Report

Merging #1077 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1077      +/-   ##
==========================================
+ Coverage   91.68%   91.69%   +<.01%     
==========================================
  Files         123      123              
  Lines        4462     4466       +4     
  Branches     1439     1441       +2     
==========================================
+ Hits         4091     4095       +4     
  Misses        157      157              
  Partials      214      214
Impacted Files Coverage Δ
src/validate/html/validateElement.ts 90.38% <100%> (+0.38%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6b956fb...bc00e20. Read the comment docs.

@Rich-Harris
Copy link
Member

Thanks for the PR! However I'm not sure this is the right solution:

  • Browsers don't care if you get the casing wrong — they'll just fix it for you. Since Svelte is designed to handle HTML the same as browsers, we should too
  • There's nothing special about viewBox — SVG has lots of attributes with weird casing, such as textLength.

For that matter, browsers don't care about casing on HTML elements either — they treat everything as though it were lowercase. Svelte doesn't, and probably should.

@emilos
Copy link
Contributor Author

emilos commented Jan 7, 2018

👍 thanks, makes sense, I wasn't sure whether svelte should case about this or not. I'll close this PR then :)

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

Successfully merging this pull request may close these issues.

case-sensitivity of SVG viewBox likely to cause silent errors
3 participants