mirror of
https://github.com/hanzoai/react.git
synced 2026-09-24 17:02:27 +00:00
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:
+13
-3
@@ -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
@@ -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
@@ -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,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user