Don't lower case HTML tags in comparison for built-ins (#21155)
Sebastian Markbåge committed
Mar 31, 2021 at 21:00 UTC
9ed01679453c7cb3c65e57f78d32c63e30a984f7
2 files changed
+5
-4
packages/react-dom/src/__tests__/ReactDOMComponent-test.js
+3
-2
@@ -1221,7 +1221,7 @@ describe('ReactDOMComponent', () => {
1221
}
1222
});
1223
1224
- it('should not duplicate uppercased selfclosing tags', () => {
1224
+ it('should warn for uppercased selfclosing tags', () => {
1225
class Container extends React.Component {
1226
render() {
1227
return React.createElement('BR', null);
@@ -1237,7 +1237,8 @@ describe('ReactDOMComponent', () => {
1237
'Use PascalCase for React components, ' +
1238
'or lowercase for HTML elements.',
1239
);
1240
- expect(returnedValue).not.toContain('</BR>');
1240
+ // This includes a duplicate tag because we didn't treat this as self-closing.
1241
+ expect(returnedValue).toContain('</BR>');
1242
});
1243
1244
it('should warn on upper case HTML tags, not SVG nor custom tags', () => {
packages/react-dom/src/server/ReactPartialRenderer.js
+2
-2
@@ -1324,7 +1324,7 @@ class ReactDOMServerRenderer {
1324
context: Object,
1325
parentNamespace: string,
1326
): string {
1327
- const tag = element.type.toLowerCase();
1327
+ const tag = element.type;
1328
1329
let namespace = parentNamespace;
1330
if (parentNamespace === HTML_NAMESPACE) {
@@ -1335,7 +1335,7 @@ class ReactDOMServerRenderer {
1335
if (namespace === HTML_NAMESPACE) {
1336
// Should this check be gated by parent namespace? Not sure we want to
1337
// allow <SVG> or <mATH>.
1338
- if (tag !== element.type) {
1338
+ if (tag.toLowerCase() !== element.type) {
1339
console.error(
1340
'<%s /> is using incorrect casing. ' +
1341
'Use PascalCase for React components, ' +