Skip to content

Commit

Permalink
Add warnings for onFocusIn and onFocusOut props
Browse files Browse the repository at this point in the history
  • Loading branch information
jontewks committed Mar 19, 2016
1 parent 67f8524 commit 8648429
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/renderers/dom/shared/ReactDOMComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ function assertValidProps(component, props) {
'those nodes are unexpectedly modified or duplicated. This is ' +
'probably not intentional.'
);
warning(
props.onFocusIn == null &&
props.onFocusOut == null,
'Props onFocusIn and onFocusOut are not supported. Use onFocus and ' +
'onBlur events instead because they are normalized across browsers.'
);
}
invariant(
props.style == null || typeof props.style === 'object',
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 @@ -1234,5 +1234,17 @@ describe('ReactDOMComponent', function() {
expect(console.error.argsForCall.length).toBe(1);
expect(console.error.argsForCall[0][0]).toContain('className');
});

it('should warn about props that are no longer supported', function() {
spyOn(console, 'error');
ReactTestUtils.renderIntoDocument(<div />);
expect(console.error.argsForCall.length).toBe(0);

ReactTestUtils.renderIntoDocument(<div onFocusIn={() => {}} />);
expect(console.error.argsForCall.length).toBe(1);

ReactTestUtils.renderIntoDocument(<div onFocusOut={() => {}} />);
expect(console.error.argsForCall.length).toBe(2);
});
});
});

0 comments on commit 8648429

Please sign in to comment.