-
Notifications
You must be signed in to change notification settings - Fork 47.6k
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
Use lower case for HTML attributes #11110
Conversation
Also verified the attribute table hasn’t changed. |
var propertyInfo = DOMProperty.getPropertyInfo(name); | ||
if (propertyInfo) { | ||
if (shouldIgnoreValue(propertyInfo, value)) { | ||
return ''; | ||
} | ||
var attributeName = propertyInfo.attributeName; | ||
if (namespace === HTML_NAMESPACE) { | ||
attributeName = attributeName.toLowerCase(); |
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.
Should this happen once, when the properties are injected?
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.
That wouldn't help with properties that aren't in the whitelist.
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.
But line 93 ensures that this code only runs when we have property info (which I believe is always from the whitelist)
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.
Ah I see. I guess we should update the custom ones too in this case.
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.
Wait. Why is this necessary? This already gets lower cased in the injection here:
https://github.com/facebook/react/blob/master/src/renderers/dom/shared/DOMProperty.js#L83
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.
Looks like tests pass when I remove this statement! (98-100). Totally need the toLowerCase
below though.
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.
Looks good, but if we can run toLowerCase
when we inject property info ahead of time, that could be nice. That might require passing the namespace into the injection function, or specifying it in the injections themselves.
Deploy preview ready! Built with commit 850550c |
4548f1b
to
850550c
Compare
I'm still not super sure it's worth it. I wonder if we can measure perf impact somehow. |
Isn't it better to warn instead? It avoids confusion and possible spreading headaches. <div fooBar={1} {...{foobar: 2}} /> But I'm guessing there's more to it than that. |
It's mostly about lower casing supported attributes. |
If this is meant for supported attributes, I think we should only do it for them. Since those are a few special cases we can compare them using interned strings (which we probably do in some places anyway?) and omit the same lower-cased interned string for each match instead of calling For custom ones we could warn but might be excessive since there might be custom ones where this is legit (although probably not). |
@sebmarkbage https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements-core-concepts
So with the exception of namespaced attributes, custom elements may not use upper-case characters either. |
Do the conflicting files mean this work needs to be rebased? Sorry, new to this. |
Yes. But we also haven't decided if we actually want to do this. |
Meh. What we're doing is technically correct. If somebody feels strongly about the output they can prettify it themselves. In practice it doesn't matter, and we don't want to take any potential perf hit there. If someone feels strongly you're welcome to provide real-world measurements demonstrating this patch has no effect on perf. |
It doesn't really matter because HTML is case insensitive but people prefer it.
Fixes #10863.