Skip to content

Commit

Permalink
Add missing single-word attributes to property warning list (#10495)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nhunzaker authored Aug 21, 2017
1 parent ec77740 commit 35859df
Show file tree
Hide file tree
Showing 4 changed files with 297 additions and 90 deletions.
3 changes: 3 additions & 0 deletions src/renderers/dom/shared/HTMLDOMPropertyConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ var HAS_OVERLOADED_BOOLEAN_VALUE =
DOMProperty.injection.HAS_OVERLOADED_BOOLEAN_VALUE;

var HTMLDOMPropertyConfig = {
// When adding attributes to this list, be sure to also add them to
// the `possibleStandardNames` module to ensure casing and incorrect
// name warnings.
Properties: {
allowFullScreen: HAS_BOOLEAN_VALUE,
// specifies target context for links with `preload` type
Expand Down
8 changes: 6 additions & 2 deletions src/renderers/dom/shared/SVGDOMPropertyConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ var NS = {
};

/**
* This is a list of all SVG attributes that need special
* casing, namespacing, or boolean value assignment.
* This is a list of all SVG attributes that need special casing,
* namespacing, or boolean value assignment.
*
* When adding attributes to this list, be sure to also add them to
* the `possibleStandardNames` module to ensure casing and incorrect
* name warnings.
*
* SVG Attributes List:
* https://www.w3.org/TR/SVG/attindex.html
Expand Down
12 changes: 12 additions & 0 deletions src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2080,6 +2080,18 @@ describe('ReactDOMComponent', () => {
'Warning: Invalid prop `whatever` on <div> tag.',
);
});

it('warns on bad casing of known HTML attributes', function() {
spyOn(console, 'error');

var el = ReactTestUtils.renderIntoDocument(<div SiZe="30" />);

expect(el.getAttribute('size')).toBe('30');

expectDev(console.error.calls.argsFor(0)[0]).toContain(
'Warning: Invalid DOM property `SiZe`. Did you mean `size`?',
);
});
});

describe('Object stringification', function() {
Expand Down
Loading

0 comments on commit 35859df

Please sign in to comment.