From b2297ae6c3117ca9b3e15aedaf73d9187eb88e6c 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) --- .../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 775d175fefc75..90080c7ff8db5 100644 --- a/src/isomorphic/classic/element/ReactElement.js +++ b/src/isomorphic/classic/element/ReactElement.js @@ -192,16 +192,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; } @@ -327,16 +317,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 fd500dce87e7c..36814982c3f1d 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', () => { expect(element.props.foo).toBe(1); }); - it('warns if the config object inherits from any type other than Object', () => { - 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', () => { 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 4d98c45f38312..50406d03456d6 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', () => { expect(ReactDOM.findDOMNode(component).childNodes[0].className).toBe('xyz'); }); - it('should warn if the config object inherits from any type other than Object', () => { - 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', () => { var config = Object.create(null, {foo: {value: 1, enumerable: true}}); React.cloneElement(
, config);