-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Warning: SVG property className is deprecated #6211
Comments
Yes, this was intentional. We could introduce a special case for As per our discussion on the team chat, we can provide a codemod to facilitate an easy migration: #6213 |
I don't remember the rationale here. We don't use class for HTML elements so why should we on SVG when there is a perfectly fine property name? I interpreted the change as "we don't block other attributes" but we can still make special cases just like we do for HTML. Web Components is only different because there is no other way and support is busted anyway. Discrepancy between HTML/SVG which have merged into a single integrated standard and are both core features of the platform seems worse than discrepancy between the core features and a feature that nobody really uses. I don't really like that we have this discrepancy without a clearer story around it (and without a major section describing in the blog post). |
Special cases suck. You have differences anyway because React html elements use camelCase and svg attributes use kebab-case, among other things... unless you want to write some fancy logic to try and normalize the differences and automatically apply transforms to recapitalize and insert hyphens. But it's pointless to perform computation and special-case checks when you could just pass them through. It's much cleaner to have a simple "pass-through" rule for svg, and we should apply that rule consistently. EDIT: Actually, you couldn't write an automatic rule, because SVG is inconsistent about the names of their attributes. You have camelCase attributes like |
Being Regarding special cases, they suck yes, but it sucks even more to use different naming for the same property if HTML element or SVG. |
Looks like there is more discussion here. |
This attribute name change also caught me by surprise. It makes it difficult to write components that work in both HTML and SVG contexts. I have a tooltip component like this that mostly* worked before v15. * save for some IE-related SVG bugs that were present before v15 |
Do you have any plans for using It seems React can use
Are there any reasons using |
I use a CSS-in-JS solution with a helper function that splats in It is kind of annoying to have this warning now. So whatever you decide to do, at least make it consistent across html and svg. I personally would prefer to remove as much whitelisting / special casing as possible. |
Renaming |
A warning message is in place, no special case for the "class" attribute is |
We're exploring a couple options. I think at the very least we'll make sure
Maybe we could do it but it definitely is a very big change. We might be too far down this path and honestly by the time we feel ready for it, we might all be using abstractions on top of the DOM (something like react-native-web for example), so it might not matter as much. I agree with what I think you're getting at though - we should probably do it all at once and not live in this hybrid world where SVG uses one pattern and HTML uses another. |
Would the list be fairly complete? I know in previous iterations of React it was missing quite a large number of tags/attributes. It's tough as just one or two of these missing can make things a lot more painful in your application's code. That being said, definitely agree with this:
|
Yea I think it would have to be totally complete. On Wednesday, March 9, 2016, Jason Killian notifications@github.com wrote:
|
In #5714, we changed SVG attribute logic to pass all SVG attributes unchanged.
This means, for example, that instead of
<svg strokeWidth>
you’d write<svg stroke-width>
.The reason for this change was that we don’t want to maintain a whitelist of attributes.
Since we released 15 RC, I saw a report on Twitter saying that
<svg className>
now also prints a warning:In a way, this makes sense, as it is consistent with us not maintaining a whitelist, and with how we treat custom components.
On the other hand, SVG elements do not seem that special, and asking people to use
class
on them instead invites the old discussion about doing that for DOM elements as well.I would like to double-check that this
className => class
is indeed a change we want to make for SVG elements. Alternatively, we can leaveclassName
as is by introducing a special case for it alone.The text was updated successfully, but these errors were encountered: