Skip to content

Commit

Permalink
Clarify ReactDOM's case warning for html tags (#12533)
Browse files Browse the repository at this point in the history
* update warning text

* update tests to match

* `yarn prettier`

* include note on HTML5 custom elements

* dan’s copy suggestion

* remove ‘letters’
  • Loading branch information
wherestheguac authored and gaearon committed Apr 4, 2018
1 parent 8ec0e4a commit 27535e7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
16 changes: 13 additions & 3 deletions packages/react-dom/src/__tests__/ReactDOMComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,11 @@ describe('ReactDOMComponent', () => {

expect(() => {
returnedValue = ReactDOMServer.renderToString(<Container />);
}).toWarnDev('<BR /> is using uppercase HTML.');
}).toWarnDev(
'<BR /> is using incorrect casing. ' +
'Use PascalCase for React components, ' +
'or lowercase for HTML elements.',
);
expect(returnedValue).not.toContain('</BR>');
});

Expand All @@ -1012,7 +1016,11 @@ describe('ReactDOMComponent', () => {

expect(() =>
ReactTestUtils.renderIntoDocument(React.createElement('IMG')),
).toWarnDev('<IMG /> is using uppercase HTML.');
).toWarnDev(
'<IMG /> is using incorrect casing. ' +
'Use PascalCase for React components, ' +
'or lowercase for HTML elements.',
);
});

it('should warn on props reserved for future use', () => {
Expand Down Expand Up @@ -1059,7 +1067,9 @@ describe('ReactDOMComponent', () => {
expect(() =>
ReactTestUtils.renderIntoDocument(<hasOwnProperty />),
).toWarnDev([
'<hasOwnProperty /> is using uppercase HTML',
'<hasOwnProperty /> is using incorrect casing. ' +
'Use PascalCase for React components, ' +
'or lowercase for HTML elements.',
'The tag <hasOwnProperty> is unrecognized in this browser',
]);
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,11 +602,13 @@ describe('ReactDOMServer', () => {
</div>,
),
).toWarnDev([
'Warning: <inPUT /> is using uppercase HTML. Always use lowercase ' +
'HTML tags in React.',
'Warning: <inPUT /> is using incorrect casing. ' +
'Use PascalCase for React components, ' +
'or lowercase for HTML elements.',
// linearGradient doesn't warn
'Warning: <iFrame /> is using uppercase HTML. Always use lowercase ' +
'HTML tags in React.',
'Warning: <iFrame /> is using incorrect casing. ' +
'Use PascalCase for React components, ' +
'or lowercase for HTML elements.',
]);
});

Expand Down
5 changes: 3 additions & 2 deletions packages/react-dom/src/client/ReactDOMFiberComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,9 @@ export function createElement(
// allow <SVG> or <mATH>.
warning(
isCustomComponentTag || type === type.toLowerCase(),
'<%s /> is using uppercase HTML. Always use lowercase HTML tags ' +
'in React.',
'<%s /> is using incorrect casing. ' +
'Use PascalCase for React components, ' +
'or lowercase for HTML elements.',
type,
);
}
Expand Down
5 changes: 3 additions & 2 deletions packages/react-dom/src/server/ReactPartialRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -955,8 +955,9 @@ class ReactDOMServerRenderer {
// allow <SVG> or <mATH>.
warning(
tag === element.type,
'<%s /> is using uppercase HTML. Always use lowercase HTML tags ' +
'in React.',
'<%s /> is using incorrect casing. ' +
'Use PascalCase for React components, ' +
'or lowercase for HTML elements.',
element.type,
);
}
Expand Down

0 comments on commit 27535e7

Please sign in to comment.