-
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
React 16 does not lowercase HTML attributes in generated HTML #10863
Comments
Since HTML attributes are case-insensitive this should work as expected. var div = document.createElement('div')
div.innerHTML = '<table cellSpacing="1" cellPadding="2"></table>'
// produces
<table cellspacing="1" cellpadding="2"></table>
div.cellPadding === "2" // true |
Yes, agreed. Though if there is an easy way to make React output these attributes lower-cased, that would be a more canonical way to format these (does it currently do this for any other attributes?) |
Seems like it doesn't matter in practice. Although I'm open to reviewing PRs that lowercase anything that is in HTML namespace. |
I'm tagging this as feature request because technically it's not a bug. But we can fix this. |
I decided not to fix this. Again, it's not a bug: technically HTML allows attributes to have any casing. We're strictly doing less work on React side, and it doesn't make sense to me to do more work to make the output more aesthetically consistent. If you feel strongly about you're welcome to provide real-world benchmarks from sites heavily using SSR that demonstrate #11110 has no impact on perf. Then we could take it. |
Hey guys, not sure why but |
Can you file a new issue for this specifically with a reproducing case? Then we could look at it. |
I believe that a strong argument in favour of lowercasing (normalising) attributes is that W3 validator marks cammel-cased attributes as an error.
While the standard might allow aRbiTrAryCasinG, W3 validator suggests that there's such thing as a normalised attribute name and that not using it can be considered an error. |
By the way, the funny thing is that React actually complains if one tries to override the attribute name to make the React output validate in the W3 validator: <table
style={props.style}
{...{
cellspacing: "0",
cellpadding: "0",
}}
> ...
|
Usecase: I want to render specific HTML strict markup for emails using React. W3 validator says the same thing as on the screenshot above. |
@gaearon So we figured out it's actually a bug. Should this issue be reopened, or another one created? |
Some frameworks, like React, use non-canonicalised attribute names. The spec and browsers allow this, but hammerhead is only checking if the attribute name without canonicalisation matches `srcset`. By using the `loweredAttr` for the comparision, hammerhead will be more accepting of inputs and resolve srcset issues with React projets (DevExpress#2958). See facebook/react#10863 for more background.
Some frameworks, like React, use non-canonicalised attribute names. The spec and browsers allow this, but hammerhead is only checking if the attribute name without canonicalisation matches `srcset`. By using the `loweredAttr` for the comparision, hammerhead will be more accepting of inputs and resolve srcset issues with React projets (fixes DevExpress#2958). See facebook/react#10863 for more background.
Some frameworks, like React, use non-canonicalised attribute names. The spec and browsers allow this, but hammerhead is only checking if the attribute name without canonicalisation matches `srcset`. By using the `loweredAttr` for the comparision, hammerhead will be more accepting of inputs and resolve srcset issues with React projets (fixes DevExpress#2958). See facebook/react#10863 for more background.
Some frameworks, like React, use non-canonicalised attribute names. The spec and browsers allow this, but hammerhead is only checking if the attribute name without canonicalisation matches `srcset`. By using the `loweredAttr` for the comparison, hammerhead will be more accepting of inputs and resolve srcset issues with React projects (fixes DevExpress#2958). See facebook/react#10863 for more background.
Some frameworks, like React, use non-canonicalised attribute names. The spec and browsers allow this, but hammerhead is only checking if the attribute name without canonicalisation matches `srcset`. By using the `loweredAttr` for the comparison, hammerhead will be more accepting of inputs and resolve srcset issues with React projects (fixes DevExpress#2958). See facebook/react#10863 for more background.
Some frameworks, like React, use non-canonicalised attribute names. The spec and browsers allow this, but hammerhead is only checking if the attribute name without canonicalisation matches `srcset`. By using the `loweredAttr` for the comparison, hammerhead will be more accepting of inputs and resolve srcset issues with React projects (fixes DevExpress#2958). See facebook/react#10863 for more background.
Some frameworks, like React, use non-canonicalised attribute names. The spec and browsers allow this, but hammerhead is only checking if the attribute name without canonicalisation matches `srcset`. By using the `loweredAttr` for the comparison, hammerhead will be more accepting of inputs and resolve srcset issues with React projects (fixes DevExpress#2958). See facebook/react#10863 for more background.
Some frameworks, like React, use non-canonicalised attribute names. The spec and browsers allow this, but hammerhead is only checking if the attribute name without canonicalisation matches `srcset`. By using the `loweredAttr` for the comparison, hammerhead will be more accepting of inputs and resolve srcset issues with React projects (fixes #2958). See facebook/react#10863 for more background.
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
ReactDOMServer generates camelCased markup for the
cellSpacing
andcellPadding
attributes:<table cellSpacing="1" cellPadding="2"></table>
(Here's an example pen: https://codepen.io/anon/pen/jGBLdP)
I believe these attributes are canonically lowercased. If I lowercase the attributes in JSX, React warns that I'm not using the right names:
Warning: Invalid DOM property `cellpadding`. Did you mean `cellPadding`?
What is the expected behavior?
The attribute names would be rendered lowercase:
<table cellspacing="1" cellpadding="2"></table>
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
This is in 16.0.0. Prior versions of React stripped these attributes.
The text was updated successfully, but these errors were encountered: