From e5df7980422ac2dc207e5c6606fe85519da7affc Mon Sep 17 00:00:00 2001 From: Jon Tewksbury Date: Fri, 18 Mar 2016 22:08:06 -0700 Subject: [PATCH] Add warnings for onFocusIn and onFocusOut props --- src/renderers/dom/shared/ReactDOMComponent.js | 5 +++++ .../dom/shared/__tests__/ReactDOMComponent-test.js | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/renderers/dom/shared/ReactDOMComponent.js b/src/renderers/dom/shared/ReactDOMComponent.js index f4a95edbe0259..f97b08bb14ddd 100644 --- a/src/renderers/dom/shared/ReactDOMComponent.js +++ b/src/renderers/dom/shared/ReactDOMComponent.js @@ -187,6 +187,11 @@ 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 no longer supported. Use onFocus and ' + + 'onBlur events instead because they are normalized across browsers.' + ); } invariant( props.style == null || typeof props.style === 'object', diff --git a/src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js b/src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js index 0fbbee1e17a9a..d932cdbf011fb 100644 --- a/src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js +++ b/src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js @@ -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(
); + expect(console.error.argsForCall.length).toBe(0); + + ReactTestUtils.renderIntoDocument(
{}} />); + expect(console.error.argsForCall.length).toBe(1); + + ReactTestUtils.renderIntoDocument(
{}} />); + expect(console.error.argsForCall.length).toBe(2); + }); }); });