Skip to content

Only purgeID on ReactDOMComponent unmount #1568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 31, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/browser/ui/ReactDOMComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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;
}

Expand Down
1 change: 0 additions & 1 deletion src/browser/ui/ReactDOMTextComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ assign(ReactDOMTextComponent.prototype, {
},

unmountComponent: function() {
// TODO: Is this necessary?
ReactComponentBrowserEnvironment.unmountIDFromEnvironment(this._rootNodeID);
}

Expand Down
2 changes: 0 additions & 2 deletions src/core/ReactCompositeComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions src/core/__tests__/ReactCompositeComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ describe('ReactCompositeComponent', function() {
render: function() {
return <div>
<Inner />
Text
</div>;
}
});
Expand All @@ -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() {
Expand Down