Clarify ReactDOM's case warning for html tags (#12533)

* update warning text

* update tests to match

* `yarn prettier`

* include note on HTML5 custom elements

* dan’s copy suggestion

* remove ‘letters’
This commit is contained in:
Nicole Levy
2018-04-04 22:21:06 +01:00
committed by Dan Abramov
parent 535406723f
commit 76ef077918
4 changed files with 25 additions and 11 deletions
+13 -3
View File
@@ -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>');
});
@@ -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', () => {
@@ -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 {
@@ -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.',
]);
});
+3 -2
View File
@@ -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,
);
}
+3 -2
View File
@@ -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,
);
}