Merge pull request #5433 from spicyj/unmount-children-order

Unmount children before unsetting DOM node info
This commit is contained in:
Ben Alpert
2015-11-09 17:38:06 -08:00
2 changed files with 17 additions and 1 deletions
@@ -1147,8 +1147,8 @@ ReactDOMComponent.Mixin = {
break;
}
ReactDOMComponentTree.uncacheNode(this);
this.unmountChildren();
ReactDOMComponentTree.uncacheNode(this);
EventPluginHub.deleteAllListeners(this);
ReactComponentBrowserEnvironment.unmountIDFromEnvironment(this._rootNodeID);
this._rootNodeID = null;
@@ -865,6 +865,22 @@ describe('ReactDOMComponent', function() {
EventPluginHub.getListener(inst, 'onClick')
).toBe(undefined);
});
it('unmounts children before unsetting DOM node info', function() {
var Inner = React.createClass({
render: function() {
return <span />;
},
componentWillUnmount: function() {
// Should not throw
expect(ReactDOM.findDOMNode(this).nodeName).toBe('SPAN');
},
});
var container = document.createElement('div');
ReactDOM.render(<div><Inner /></div>, container);
ReactDOM.unmountComponentAtNode(container);
});
});
describe('onScroll warning', function() {