Skip to content

Commit a170629

Browse files
committed
Merge pull request #1568 from syranide/dompurge
Only purgeID on ReactDOMComponent and ReactDOMTextComponent unmount
2 parents 508b625 + a7f0fb7 commit a170629

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

src/browser/ui/ReactDOMComponent.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ var CSSPropertyOperations = require('CSSPropertyOperations');
1818
var DOMProperty = require('DOMProperty');
1919
var DOMPropertyOperations = require('DOMPropertyOperations');
2020
var ReactBrowserEventEmitter = require('ReactBrowserEventEmitter');
21+
var ReactComponentBrowserEnvironment =
22+
require('ReactComponentBrowserEnvironment');
2123
var ReactMount = require('ReactMount');
2224
var ReactMultiChild = require('ReactMultiChild');
2325
var ReactPerf = require('ReactPerf');
@@ -475,7 +477,7 @@ ReactDOMComponent.Mixin = {
475477
unmountComponent: function() {
476478
this.unmountChildren();
477479
ReactBrowserEventEmitter.deleteAllListeners(this._rootNodeID);
478-
ReactMount.purgeID(this._rootNodeID);
480+
ReactComponentBrowserEnvironment.unmountIDFromEnvironment(this._rootNodeID);
479481
this._rootNodeID = null;
480482
}
481483

src/browser/ui/ReactDOMTextComponent.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ assign(ReactDOMTextComponent.prototype, {
108108
},
109109

110110
unmountComponent: function() {
111-
// TODO: Is this necessary?
112111
ReactComponentBrowserEnvironment.unmountIDFromEnvironment(this._rootNodeID);
113112
}
114113

src/core/ReactCompositeComponent.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,6 @@ var ReactCompositeComponentMixin = {
257257
this._pendingCallbacks = null;
258258
this._pendingElement = null;
259259

260-
ReactComponentEnvironment.unmountIDFromEnvironment(this._rootNodeID);
261-
262260
// These fields do not really need to be reset since this object is no
263261
// longer accessible.
264262
this._context = null;

src/core/__tests__/ReactCompositeComponent-test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ describe('ReactCompositeComponent', function() {
431431
render: function() {
432432
return <div>
433433
<Inner />
434+
Text
434435
</div>;
435436
}
436437
});
@@ -452,11 +453,11 @@ describe('ReactCompositeComponent', function() {
452453
React.unmountComponentAtNode(container);
453454
expect(innerUnmounted).toBe(true);
454455

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.
457458
// TODO: Test the effect of this. E.g. does the node cache get repopulated
458459
// after a getDOMNode call?
459-
expect(ReactMount.purgeID.callCount).toBe(6);
460+
expect(ReactMount.purgeID.callCount).toBe(3);
460461
});
461462

462463
it('should warn when shouldComponentUpdate() returns undefined', function() {

0 commit comments

Comments
 (0)