-
Notifications
You must be signed in to change notification settings - Fork 660
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
map className to class when updating htmlAttributes #205
Conversation
694fdf8
to
917fea9
Compare
Ping ✨ |
@koenpunt Thanks for your patience. If you look at how we handled things like |
expect(htmlTag.getAttribute("class")).to.equal("myClassName"); | ||
expect(htmlTag.getAttribute(HELMET_ATTRIBUTE)).to.equal("class"); | ||
}); | ||
|
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.
Also a client and server side test would be optimal. Thank you.
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.
Missed the server section in the test file, will look into adding a test
REACT_TAG_MAP is for conversion the other way around, and looking up a property by its value isn't too efficient IMO. |
Updated per request |
All the other Helmet props take html keys in their objects, but htmlAttributes will be the only one that takes React keys, this could be confusing for people as the API doesn't match:
|
You got a point there. Makes me think that these html keys actually should've been React keys in the first place. Would you accept a PR to flip that, of course with deprecation warnings in place? |
@koenpunt I'd rather not change the whole API for this one feature. If you could switch your solution to use REACT_TAG_MAP it would be the simplest. |
Having just html keys seems more declarative to me because what you are putting in is exactly what you will get out. Because these keys are in an object and not passed directly to the component we aren't forced to use camel casing like React props. And if you are rendering on the server as a string you never have to do any conversion. |
Why is it that |
@koenpunt excellent point, we have been meaning to convert the logic to use We don't use the |
@koenpunt Just merged a PR that is using |
0b64ebd
to
f393dc8
Compare
f393dc8
to
6de3b64
Compare
Updated, need me to squash some of these commits? Also I expect people complaining about the inconsistency between |
This introduces a mapping of React attributes (e.g.
className
) to html attributes (class
).If other attributes have to be mapped later on they can be added easily to the
HTML_TAG_MAP
object.should fix #204