Merge pull request #3727 from spicyj/dsih

Relax dangerouslySetInnerHTML validation
This commit is contained in:
Ben Alpert 2015-04-22 17:37:40 -07:00
commit 0183f70797
2 changed files with 8 additions and 1 deletions

View File

@ -72,7 +72,8 @@ function assertValidProps(component, props) {
'Can only set one of `children` or `props.dangerouslySetInnerHTML`.'
);
invariant(
props.dangerouslySetInnerHTML.__html != null,
typeof props.dangerouslySetInnerHTML === 'object' &&
'__html' in props.dangerouslySetInnerHTML,
'`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. ' +
'Please visit https://fb.me/react-invariant-dangerously-set-inner-html ' +
'for more information.'

View File

@ -443,6 +443,12 @@ describe('ReactDOMComponent', function() {
);
});
it('should allow {__html: null}', function() {
expect(function() {
mountComponent({dangerouslySetInnerHTML: {__html: null} });
}).not.toThrow();
});
it("should warn about contentEditable and children", function() {
spyOn(console, 'error');
mountComponent({contentEditable: true, children: ''});