From 12690341ee64ce4695063406e17b81dac6edbb9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Markb=C3=A5ge?= Date: Wed, 31 Mar 2021 21:00:22 -0400 Subject: [PATCH] Don't lower case HTML tags in comparison for built-ins (#21155) --- packages/react-dom/src/__tests__/ReactDOMComponent-test.js | 5 +++-- packages/react-dom/src/server/ReactPartialRenderer.js | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/react-dom/src/__tests__/ReactDOMComponent-test.js b/packages/react-dom/src/__tests__/ReactDOMComponent-test.js index b064540a8ddf5..2911099e8e932 100644 --- a/packages/react-dom/src/__tests__/ReactDOMComponent-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMComponent-test.js @@ -1221,7 +1221,7 @@ describe('ReactDOMComponent', () => { } }); - it('should not duplicate uppercased selfclosing tags', () => { + it('should warn for uppercased selfclosing tags', () => { class Container extends React.Component { render() { return React.createElement('BR', null); @@ -1237,7 +1237,8 @@ describe('ReactDOMComponent', () => { 'Use PascalCase for React components, ' + 'or lowercase for HTML elements.', ); - expect(returnedValue).not.toContain('
'); + // This includes a duplicate tag because we didn't treat this as self-closing. + expect(returnedValue).toContain('
'); }); it('should warn on upper case HTML tags, not SVG nor custom tags', () => { diff --git a/packages/react-dom/src/server/ReactPartialRenderer.js b/packages/react-dom/src/server/ReactPartialRenderer.js index 1e536e5cdd496..92cd79fde30c0 100644 --- a/packages/react-dom/src/server/ReactPartialRenderer.js +++ b/packages/react-dom/src/server/ReactPartialRenderer.js @@ -1324,7 +1324,7 @@ class ReactDOMServerRenderer { context: Object, parentNamespace: string, ): string { - const tag = element.type.toLowerCase(); + const tag = element.type; let namespace = parentNamespace; if (parentNamespace === HTML_NAMESPACE) { @@ -1335,7 +1335,7 @@ class ReactDOMServerRenderer { if (namespace === HTML_NAMESPACE) { // Should this check be gated by parent namespace? Not sure we want to // allow or . - if (tag !== element.type) { + if (tag.toLowerCase() !== element.type) { console.error( '<%s /> is using incorrect casing. ' + 'Use PascalCase for React components, ' +