-
Notifications
You must be signed in to change notification settings - Fork 47.5k
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
Add full support for SVG 1.1 #938
Conversation
Added missing elements from the list at http://www.w3.org/TR/SVG/eltindex.html
All the attributes listed here except for the event related ones http://www.w3.org/TR/SVG/attindex.html
Wow thanks! We hold off on adding all of them in the past because it's a lot of bytes. Do you mind telling us what's the gzipped size of react.min.js before and after your change? |
Before: 28667 The property name mapping is likely most of that. Using flags for naming rules might save a lot of space since there are only a couple different methods. There would be a performance tradeoff most likely though. Maybe do some sort of name transform result caching?
|
I tested a method where I used flags to determine naming rules. It reduced the size down to 30979. |
I could pull all styling attributes out since those can be set via CSS or the style attribute. That might help reduce the size even more. |
Something to keep in mind is that this reserves a lot of names for JSX, that people most likely have never heard of or expect to have been reserved. It kind of feels like this should be namespaced using To me it also kind of seems like the best approach to something big like this, that most likely won't use, would be if it could be injected instead. |
@syranide Only the element names would have conflicts with naming. Since the elements are all camelCased and it is good practice to uppercase your own components, I don't see any real conflict. IMHO I don't think it is worth removing almost HTML/SVG markup parity for such an easily avoidable scenario. |
feTurbulence: false, | ||
filter: false, | ||
font: false, | ||
'font-face': false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tested that this even works? I'm not sure if the transform actually will parse hyphenated tags.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And while it may work here, the transform step definitely doesn't allow hyphenated nodes - <font-face>
gets transformed to React.DOM.font-face
.
@syranide - I like the idea of injection. We need to make the transform step injectible though too to make this really viable. I guess we should probably do this as-is for the time being, even though I'm not wild about the noise. So a couple things I'd like to see:
|
@zpao I guess, if we still require the docblock, it would perhaps make sense to just make it |
Everything listed here http://www.w3.org/TR/SVG/propidx.html
I updated the PR by removing all the attributes that can be set via CSS. That is everything listed here http://www.w3.org/TR/SVG/propidx.html
|
In addition to everything I mentioned above, I would like you to actually build and use this. It's apparent that you haven't.
|
I don't know if this PR still has a future, but I would really like a complete support of SVG! |
@ericflo If you want to help with the tasks outlined in this PR, I would welcome patches to my fork to finish this off. |
#1009 may split |
Would love to get access to some of the missing SVG elements somehow - whether it's this PR or via #1009 - any progress updates on either of these? |
#1009 isn't going to add anything, just reorganize some code. |
Won't really make it easier, just slightly more clear where they go. |
Ah ok, maybe change the description then - the first sentence literally says "This makes it a little easier to add SVG properties." |
Ping, what's the status here? |
+1, need support for the |
#760 is now decided (JSX member expressions, But personally I feel like there are just too many generic SVG tags ( |
For what it's worth here's my branch that adds the Works well enough for me, but I'd love to see proper SVG support at some point. |
I forked this and got it up to date with the latest, diff is here: JustinTulloss/react@facebook:master...svg-support It still doesn't work correctly with namespaced attributes and I'm not going to spend the time right now to fix it, but if somebody else wants to put in any effort my branch is at least a little more up to date and works at all (the original pull request wasn't quite complete). |
Going to close this out as it's broken in its current form. Happy to look at new PRs, though we'll need a good answer to what to do with namespaced attributes. |
Adds all the missing elements from http://www.w3.org/TR/SVG/eltindex.html
Adds all the missing attributes, except for the event related ones (starting with 'on') from http://www.w3.org/TR/SVG/attindex.html
Updates documentation.
Adds support for namespaced attributes that need
setAttributeNS
I have signed the CLA