Only add children when there are children
Josh Perez committed
Jan 16, 2016 at 21:21 UTC
3da6e2889bcb4df086bbfc14eb19ac7cade2beef
2 files changed
+12
-1
src/renderers/dom/client/wrappers/ReactDOMOption.js
+4
-1
@@ -85,7 +85,10 @@ var ReactDOMOption = {
85
}
86
});
87
88
- nativeProps.children = content;
88
+ if (content) {
89
+ nativeProps.children = content;
90
+ }
91
+
92
return nativeProps;
93
},
94
src/renderers/dom/client/wrappers/__tests__/ReactDOMOption-test.js
+8
@@ -63,4 +63,12 @@ describe('ReactDOMOption', function() {
63
expect(console.error.calls.length).toBe(0);
64
expect(node.innerHTML).toBe('1 2');
65
});
66
+
67
+ it('should be able to use dangerouslySetInnerHTML on option', function() {
68
+ var stub = <option dangerouslySetInnerHTML={{ __html: 'foobar' }} />;
69
+ stub = ReactTestUtils.renderIntoDocument(stub);
70
+
71
+ var node = ReactDOM.findDOMNode(stub);
72
+ expect(node.innerHTML).toBe('foobar');
73
+ });
74
});