Added additional test case for ReactFiberBeginWork reset-text
Brian Vaughn committed
Dec 7, 2016 at 13:54 UTC
ae752dd5504c6d27a8e5cffeb2281705b2924623
1 file changed
+16
src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
+16
@@ -426,6 +426,22 @@ describe('ReactDOMComponent', () => {
426
expect(container.firstChild.innerHTML).toEqual('bonjour');
427
});
428
429
+ it('should reset innerHTML when switching from a direct text child to an empty child', () => {
430
+ const transitionToValues = [
431
+ null,
432
+ undefined,
433
+ false,
434
+ ];
435
+ transitionToValues.forEach((transitionToValue) => {
436
+ var container = document.createElement('div');
437
+ ReactDOM.render(<div>bonjour</div>, container);
438
+ expect(container.firstChild.innerHTML).toEqual('bonjour');
439
+
440
+ ReactDOM.render(<div>{transitionToValue}</div>, container);
441
+ expect(container.firstChild.innerHTML).toEqual('');
442
+ });
443
+ });
444
+
445
it('should empty element when removing innerHTML', () => {
446
var container = document.createElement('div');
447
ReactDOM.render(<div dangerouslySetInnerHTML={{__html: ':)'}} />, container);