@samitouri / QOS-React / commits / 586653935c

Unmount children before unsetting DOM node info

Ben Alpert committed Nov 9, 2015 at 15:03 UTC 586653935cbd29bb838335d218afa06536779a11
2 files changed +17 -1
src/renderers/dom/shared/ReactDOMComponent.js
+1 -1
@@ -1147,8 +1147,8 @@ ReactDOMComponent.Mixin = {
1147 break;
1148 }
1149
1150 - ReactDOMComponentTree.uncacheNode(this);
1150 this.unmountChildren();
1151 + ReactDOMComponentTree.uncacheNode(this);
1152 EventPluginHub.deleteAllListeners(this);
1153 ReactComponentBrowserEnvironment.unmountIDFromEnvironment(this._rootNodeID);
1154 this._rootNodeID = null;
src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
+16
@@ -865,6 +865,22 @@ describe('ReactDOMComponent', function() {
865 EventPluginHub.getListener(inst, 'onClick')
866 ).toBe(undefined);
867 });
868 +
869 + it('unmounts children before unsetting DOM node info', function() {
870 + var Inner = React.createClass({
871 + render: function() {
872 + return <span />;
873 + },
874 + componentWillUnmount: function() {
875 + // Should not throw
876 + expect(ReactDOM.findDOMNode(this).nodeName).toBe('SPAN');
877 + },
878 + });
879 +
880 + var container = document.createElement('div');
881 + ReactDOM.render(<div><Inner /></div>, container);
882 + ReactDOM.unmountComponentAtNode(container);
883 + });
884 });
885
886 describe('onScroll warning', function() {