From ba62748217862570c3f6c5454cfe5d189db7ce52 Mon Sep 17 00:00:00 2001 From: Stephen John Sorensen Date: Tue, 13 Sep 2016 22:15:07 -0400 Subject: [PATCH] remove plain object warning (#7724) (cherry picked from commit b2297ae6c3117ca9b3e15aedaf73d9187eb88e6c) --- .../classic/element/ReactElement.js | 20 ------------------- .../element/__tests__/ReactElement-test.js | 12 ----------- .../__tests__/ReactElementClone-test.js | 12 ----------- 3 files changed, 44 deletions(-) diff --git a/src/isomorphic/classic/element/ReactElement.js b/src/isomorphic/classic/element/ReactElement.js index 3a9d11d84cd0b..64a0e13e143db 100644 --- a/src/isomorphic/classic/element/ReactElement.js +++ b/src/isomorphic/classic/element/ReactElement.js @@ -204,16 +204,6 @@ ReactElement.createElement = function(type, config, children) { var source = null; if (config != null) { - if (__DEV__) { - warning( - /* eslint-disable no-proto */ - config.__proto__ == null || config.__proto__ === Object.prototype, - /* eslint-enable no-proto */ - 'React.createElement(...): Expected props argument to be a plain object. ' + - 'Properties defined in its prototype chain will be ignored.' - ); - } - if (hasValidRef(config)) { ref = config.ref; } @@ -334,16 +324,6 @@ ReactElement.cloneElement = function(element, config, children) { var owner = element._owner; if (config != null) { - if (__DEV__) { - warning( - /* eslint-disable no-proto */ - config.__proto__ == null || config.__proto__ === Object.prototype, - /* eslint-enable no-proto */ - 'React.cloneElement(...): Expected props argument to be a plain object. ' + - 'Properties defined in its prototype chain will be ignored.' - ); - } - if (hasValidRef(config)) { // Silently steal the ref from the parent. ref = config.ref; diff --git a/src/isomorphic/classic/element/__tests__/ReactElement-test.js b/src/isomorphic/classic/element/__tests__/ReactElement-test.js index 353989ad6b089..7ba957d15757d 100644 --- a/src/isomorphic/classic/element/__tests__/ReactElement-test.js +++ b/src/isomorphic/classic/element/__tests__/ReactElement-test.js @@ -188,18 +188,6 @@ describe('ReactElement', function() { expect(element.props.foo).toBe(1); }); - it('warns if the config object inherits from any type other than Object', function() { - spyOn(console, 'error'); - React.createElement('div', {foo: 1}); - expect(console.error).not.toHaveBeenCalled(); - React.createElement('div', Object.create({foo: 1})); - expect(console.error.calls.count()).toBe(1); - expect(console.error.calls.argsFor(0)[0]).toContain( - 'React.createElement(...): Expected props argument to be a plain object. ' + - 'Properties defined in its prototype chain will be ignored.' - ); - }); - it('extracts key and ref from the config', function() { var element = React.createFactory(ComponentClass)({ key: '12', diff --git a/src/isomorphic/classic/element/__tests__/ReactElementClone-test.js b/src/isomorphic/classic/element/__tests__/ReactElementClone-test.js index df62052aeedda..af5417a3cf837 100644 --- a/src/isomorphic/classic/element/__tests__/ReactElementClone-test.js +++ b/src/isomorphic/classic/element/__tests__/ReactElementClone-test.js @@ -75,18 +75,6 @@ describe('ReactElementClone', function() { expect(ReactDOM.findDOMNode(component).childNodes[0].className).toBe('xyz'); }); - it('should warn if the config object inherits from any type other than Object', function() { - spyOn(console, 'error'); - React.cloneElement('div', {foo: 1}); - expect(console.error).not.toHaveBeenCalled(); - React.cloneElement('div', Object.create({foo: 1})); - expect(console.error.calls.count()).toBe(1); - expect(console.error.calls.argsFor(0)[0]).toContain( - 'React.cloneElement(...): Expected props argument to be a plain object. ' + - 'Properties defined in its prototype chain will be ignored.' - ); - }); - it('does not fail if config has no prototype', function() { var config = Object.create(null, {foo: {value: 1, enumerable: true}}); React.cloneElement(
, config);