Skip to content

Commit 35859df

Browse files
authored
Add missing single-word attributes to property warning list (#10495)
* Add missing single-word attributes to property warning list * Alphabetize svg and html configs in possible names * Add basic test coverage for known single word attributes * Add note about including whitelist properites in `possibleStandardNames * Also add attribute sync comment to possibleStandardNames
1 parent ec77740 commit 35859df

File tree

4 files changed

+297
-90
lines changed

4 files changed

+297
-90
lines changed

src/renderers/dom/shared/HTMLDOMPropertyConfig.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ var HAS_OVERLOADED_BOOLEAN_VALUE =
2222
DOMProperty.injection.HAS_OVERLOADED_BOOLEAN_VALUE;
2323

2424
var HTMLDOMPropertyConfig = {
25+
// When adding attributes to this list, be sure to also add them to
26+
// the `possibleStandardNames` module to ensure casing and incorrect
27+
// name warnings.
2528
Properties: {
2629
allowFullScreen: HAS_BOOLEAN_VALUE,
2730
// specifies target context for links with `preload` type

src/renderers/dom/shared/SVGDOMPropertyConfig.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@ var NS = {
1717
};
1818

1919
/**
20-
* This is a list of all SVG attributes that need special
21-
* casing, namespacing, or boolean value assignment.
20+
* This is a list of all SVG attributes that need special casing,
21+
* namespacing, or boolean value assignment.
22+
*
23+
* When adding attributes to this list, be sure to also add them to
24+
* the `possibleStandardNames` module to ensure casing and incorrect
25+
* name warnings.
2226
*
2327
* SVG Attributes List:
2428
* https://www.w3.org/TR/SVG/attindex.html

src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2080,6 +2080,18 @@ describe('ReactDOMComponent', () => {
20802080
'Warning: Invalid prop `whatever` on <div> tag.',
20812081
);
20822082
});
2083+
2084+
it('warns on bad casing of known HTML attributes', function() {
2085+
spyOn(console, 'error');
2086+
2087+
var el = ReactTestUtils.renderIntoDocument(<div SiZe="30" />);
2088+
2089+
expect(el.getAttribute('size')).toBe('30');
2090+
2091+
expectDev(console.error.calls.argsFor(0)[0]).toContain(
2092+
'Warning: Invalid DOM property `SiZe`. Did you mean `size`?',
2093+
);
2094+
});
20832095
});
20842096

20852097
describe('Object stringification', function() {

0 commit comments

Comments
 (0)