Skip to content
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

Clarify ReactDOM's case warning for html tags #12533

Merged
merged 6 commits into from
Apr 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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