Skip to content

Commit

Permalink
Don't lower case HTML tags in comparison for built-ins (facebook#21155)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage authored and acdlite committed Apr 13, 2021
1 parent f6f9257 commit 1269034
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/react-dom/src/__tests__/ReactDOMComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -1237,7 +1237,8 @@ describe('ReactDOMComponent', () => {
'Use PascalCase for React components, ' +
'or lowercase for HTML elements.',
);
expect(returnedValue).not.toContain('</BR>');
// This includes a duplicate tag because we didn't treat this as self-closing.
expect(returnedValue).toContain('</BR>');
});

it('should warn on upper case HTML tags, not SVG nor custom tags', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/src/server/ReactPartialRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -1335,7 +1335,7 @@ class ReactDOMServerRenderer {
if (namespace === HTML_NAMESPACE) {
// Should this check be gated by parent namespace? Not sure we want to
// allow <SVG> or <mATH>.
if (tag !== element.type) {
if (tag.toLowerCase() !== element.type) {
console.error(
'<%s /> is using incorrect casing. ' +
'Use PascalCase for React components, ' +
Expand Down

0 comments on commit 1269034

Please sign in to comment.