Skip to content

Commit

Permalink
Add unknown property warning for use of (#6461)
Browse files Browse the repository at this point in the history
  • Loading branch information
hkal authored and aweary committed Sep 3, 2016
1 parent a09d158 commit 6a525fd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/renderers/dom/shared/HTMLDOMPropertyConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var HTMLDOMPropertyConfig = {
async: HAS_BOOLEAN_VALUE,
autoComplete: 0,
// autoFocus is polyfilled/normalized by AutoFocusUtils
// autoFocus: HAS_BOOLEAN_VALUE,
autoFocus: HAS_BOOLEAN_VALUE,
autoPlay: HAS_BOOLEAN_VALUE,
capture: HAS_BOOLEAN_VALUE,
cellPadding: 0,
Expand Down Expand Up @@ -205,6 +205,7 @@ var HTMLDOMPropertyConfig = {
},
DOMAttributeNames: {
acceptCharset: 'accept-charset',
autoFocus: 'autofocus',
className: 'class',
htmlFor: 'for',
httpEquiv: 'http-equiv',
Expand Down
17 changes: 17 additions & 0 deletions src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1495,5 +1495,22 @@ describe('ReactDOMComponent', function() {
//since hard coding the line number would make test too brittle
expect(parseInt(previousLine, 10) + 12).toBe(parseInt(currentLine, 10));
});

it('should suggest property name if available', () => {
spyOn(console, 'error');

ReactTestUtils.renderIntoDocument(React.createElement('label', {for: 'test'}));
ReactTestUtils.renderIntoDocument(React.createElement('input', {type: 'text', autofocus: true}));

expect(console.error.calls.count()).toBe(2);

expect(console.error.calls.argsFor(0)[0]).toBe(
'Warning: Unknown DOM property for. Did you mean htmlFor?\n in label'
);

expect(console.error.calls.argsFor(1)[0]).toBe(
'Warning: Unknown DOM property autofocus. Did you mean autoFocus?\n in input'
);
});
});
});

0 comments on commit 6a525fd

Please sign in to comment.