Only purgeID on ReactDOMComponent and ReactDOMTextComponent unmount
syranide committed
Jan 30, 2015 at 21:32 UTC
a7f0fb7c4f95ab9abb58d3a056a958373d6666b1
4 files changed
+7
-7
src/browser/ui/ReactDOMComponent.js
+3
-1
@@ -18,6 +18,8 @@ var CSSPropertyOperations = require('CSSPropertyOperations');
18
var DOMProperty = require('DOMProperty');
19
var DOMPropertyOperations = require('DOMPropertyOperations');
20
var ReactBrowserEventEmitter = require('ReactBrowserEventEmitter');
21
+var ReactComponentBrowserEnvironment =
22
+ require('ReactComponentBrowserEnvironment');
23
var ReactMount = require('ReactMount');
24
var ReactMultiChild = require('ReactMultiChild');
25
var ReactPerf = require('ReactPerf');
@@ -475,7 +477,7 @@ ReactDOMComponent.Mixin = {
477
unmountComponent: function() {
478
this.unmountChildren();
479
ReactBrowserEventEmitter.deleteAllListeners(this._rootNodeID);
478
- ReactMount.purgeID(this._rootNodeID);
480
+ ReactComponentBrowserEnvironment.unmountIDFromEnvironment(this._rootNodeID);
481
this._rootNodeID = null;
482
}
483
src/browser/ui/ReactDOMTextComponent.js
-1
@@ -108,7 +108,6 @@ assign(ReactDOMTextComponent.prototype, {
108
},
109
110
unmountComponent: function() {
111
- // TODO: Is this necessary?
111
ReactComponentBrowserEnvironment.unmountIDFromEnvironment(this._rootNodeID);
112
}
113
src/core/ReactCompositeComponent.js
-2
@@ -257,8 +257,6 @@ var ReactCompositeComponentMixin = {
257
this._pendingCallbacks = null;
258
this._pendingElement = null;
259
260
- ReactComponentEnvironment.unmountIDFromEnvironment(this._rootNodeID);
261
-
260
// These fields do not really need to be reset since this object is no
261
// longer accessible.
262
this._context = null;
src/core/__tests__/ReactCompositeComponent-test.js
+4
-3
@@ -431,6 +431,7 @@ describe('ReactCompositeComponent', function() {
431
render: function() {
432
return <div>
433
<Inner />
434
+ Text
435
</div>;
436
}
437
});
@@ -452,11 +453,11 @@ describe('ReactCompositeComponent', function() {
453
React.unmountComponentAtNode(container);
454
expect(innerUnmounted).toBe(true);
455
455
- // <Component />, <Inner />, and both <div /> elements and their wrappers
456
- // each call unmountIDFromEnvironment which calls purgeID, for a total of 6.
456
+ // The text and both <div /> elements and their wrappers each call
457
+ // unmountIDFromEnvironment which calls purgeID, for a total of 3.
458
// TODO: Test the effect of this. E.g. does the node cache get repopulated
459
// after a getDOMNode call?
459
- expect(ReactMount.purgeID.callCount).toBe(6);
460
+ expect(ReactMount.purgeID.callCount).toBe(3);
461
});
462
463
it('should warn when shouldComponentUpdate() returns undefined', function() {