-
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
SVG attributes and ARIA attributes with different pattern #5617
Comments
I think the |
If I had to guess, the most likely reasoning here is that aria-* isn't completely supported by HTML5 spec. "There are many ARIA roles and properties that are not provided by native elements and attributes in HTML5": https://www.paciellogroup.com/blog/2010/04/html5-and-the-myth-of-wai-aria-redundance/ |
Just to reinforce this, here's where React checks for custom attributes (either |
Also see this explanation here: https://github.com/facebook/react/blob/master/src/renderers/dom/shared/DOMProperty.js#L39 |
Now that #5714 is merged, starting from the next release all SVG attributes will be passed through as is, just like DOM attributes are treated differently because React occasionally normalizes their behavior across the browsers and does some other magic which it doesn't do for the cases above. |
Thanks for working on this Dan @gaearon! |
Hi, related to this issue I'm trying to use a SVG with aria-* attributes as a component and React is complaining about unknown props on tag:
Looking at the docs it seems both Right now my workaround is to use |
My bad, i tried with just |
I'm not sure why it is not working for you. I've been using |
Hi, My bad! I investigated further the issue and I've found this issue. Sorry! |
I have the following JSX sample, which is a SVG element:
In raw HTML
strokeWidth
is represented asstroke-width
. It seems to me that all JSX attributes follow the camel-case format. So, I immediately thought on addingariaLabel
instead ofaria-label
.Question: Is there a pattern for JSX attributes? If yes, why
aria-*
does not follow this pattern?In fact, I like the idea of having
stroke-*
so that I don't have to preprocess my raw svg to reactjs.I understand that this could be the expected behavior, but I'm just trying to understand why the patterns are different for aria and svg.
The text was updated successfully, but these errors were encountered: