@samitouri / QOS-React-2 / commits / 7f02455220

Relax dangerouslySetInnerHTML validation

Fixes #3460.

Ben Alpert committed Apr 22, 2015 at 16:58 UTC 7f024552207f1a67a7748bdfbd21234ff0d3b9db
2 files changed +8 -1
src/browser/ui/ReactDOMComponent.js
+2 -1
@@ -72,7 +72,8 @@ function assertValidProps(component, props) {
72 'Can only set one of `children` or `props.dangerouslySetInnerHTML`.'
73 );
74 invariant(
75 - props.dangerouslySetInnerHTML.__html != null,
75 + typeof props.dangerouslySetInnerHTML === 'object' &&
76 + '__html' in props.dangerouslySetInnerHTML,
77 '`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. ' +
78 'Please visit https://fb.me/react-invariant-dangerously-set-inner-html ' +
79 'for more information.'
src/browser/ui/__tests__/ReactDOMComponent-test.js
+6
@@ -443,6 +443,12 @@ describe('ReactDOMComponent', function() {
443 );
444 });
445
446 + it('should allow {__html: null}', function() {
447 + expect(function() {
448 + mountComponent({dangerouslySetInnerHTML: {__html: null} });
449 + }).not.toThrow();
450 + });
451 +
452 it("should warn about contentEditable and children", function() {
453 spyOn(console, 'error');
454 mountComponent({contentEditable: true, children: ''});