Merge pull request #1568 from syranide/dompurge
Only purgeID on ReactDOMComponent and ReactDOMTextComponent unmount
This commit is contained in:
commit
a170629128
|
@ -18,6 +18,8 @@ var CSSPropertyOperations = require('CSSPropertyOperations');
|
|||
var DOMProperty = require('DOMProperty');
|
||||
var DOMPropertyOperations = require('DOMPropertyOperations');
|
||||
var ReactBrowserEventEmitter = require('ReactBrowserEventEmitter');
|
||||
var ReactComponentBrowserEnvironment =
|
||||
require('ReactComponentBrowserEnvironment');
|
||||
var ReactMount = require('ReactMount');
|
||||
var ReactMultiChild = require('ReactMultiChild');
|
||||
var ReactPerf = require('ReactPerf');
|
||||
|
@ -475,7 +477,7 @@ ReactDOMComponent.Mixin = {
|
|||
unmountComponent: function() {
|
||||
this.unmountChildren();
|
||||
ReactBrowserEventEmitter.deleteAllListeners(this._rootNodeID);
|
||||
ReactMount.purgeID(this._rootNodeID);
|
||||
ReactComponentBrowserEnvironment.unmountIDFromEnvironment(this._rootNodeID);
|
||||
this._rootNodeID = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -108,7 +108,6 @@ assign(ReactDOMTextComponent.prototype, {
|
|||
},
|
||||
|
||||
unmountComponent: function() {
|
||||
// TODO: Is this necessary?
|
||||
ReactComponentBrowserEnvironment.unmountIDFromEnvironment(this._rootNodeID);
|
||||
}
|
||||
|
||||
|
|
|
@ -257,8 +257,6 @@ var ReactCompositeComponentMixin = {
|
|||
this._pendingCallbacks = null;
|
||||
this._pendingElement = null;
|
||||
|
||||
ReactComponentEnvironment.unmountIDFromEnvironment(this._rootNodeID);
|
||||
|
||||
// These fields do not really need to be reset since this object is no
|
||||
// longer accessible.
|
||||
this._context = null;
|
||||
|
|
|
@ -431,6 +431,7 @@ describe('ReactCompositeComponent', function() {
|
|||
render: function() {
|
||||
return <div>
|
||||
<Inner />
|
||||
Text
|
||||
</div>;
|
||||
}
|
||||
});
|
||||
|
@ -452,11 +453,11 @@ describe('ReactCompositeComponent', function() {
|
|||
React.unmountComponentAtNode(container);
|
||||
expect(innerUnmounted).toBe(true);
|
||||
|
||||
// <Component />, <Inner />, and both <div /> elements and their wrappers
|
||||
// each call unmountIDFromEnvironment which calls purgeID, for a total of 6.
|
||||
// The text and both <div /> elements and their wrappers each call
|
||||
// unmountIDFromEnvironment which calls purgeID, for a total of 3.
|
||||
// TODO: Test the effect of this. E.g. does the node cache get repopulated
|
||||
// after a getDOMNode call?
|
||||
expect(ReactMount.purgeID.callCount).toBe(6);
|
||||
expect(ReactMount.purgeID.callCount).toBe(3);
|
||||
});
|
||||
|
||||
it('should warn when shouldComponentUpdate() returns undefined', function() {
|
||||
|
|
Loading…
Reference in New Issue