From 35484e57c91d67d5ddd59eaf952e771bc95872c5 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 24 Feb 2016 20:32:51 +0100 Subject: [PATCH] Add surpressContentEditableWarning See #5837 --- src/renderers/dom/shared/ReactDOMComponent.js | 4 +++- .../dom/shared/__tests__/ReactDOMComponent-test.js | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/renderers/dom/shared/ReactDOMComponent.js b/src/renderers/dom/shared/ReactDOMComponent.js index ae3f783eb7c9a..4ddb40d1faadf 100644 --- a/src/renderers/dom/shared/ReactDOMComponent.js +++ b/src/renderers/dom/shared/ReactDOMComponent.js @@ -174,7 +174,9 @@ function assertValidProps(component, props) { 'For more information, lookup documentation on `dangerouslySetInnerHTML`.' ); warning( - !props.contentEditable || props.children == null, + props.surpressContentEditableWarning || + !props.contentEditable || + props.children == null, 'A component is `contentEditable` and contains `children` managed by ' + 'React. It is now your responsibility to guarantee that none of ' + 'those nodes are unexpectedly modified or duplicated. This is ' + diff --git a/src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js b/src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js index 5e7ecb6452a5e..3bae74a04b3da 100644 --- a/src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js +++ b/src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js @@ -947,6 +947,12 @@ describe('ReactDOMComponent', function() { expect(console.error.argsForCall[0][0]).toContain('contentEditable'); }); + it('should respect suppressContentEditableWarning', function() { + spyOn(console, 'error'); + mountComponent({contentEditable: true, children: '', suppressContentEditableWarning: true}); + expect(console.error.argsForCall.length).toBe(0); + }); + it('should validate against invalid styles', function() { expect(function() { mountComponent({style: 'display: none'});