Skip to content

Commit 067547c

Browse files
committed
Merge pull request facebook#5689 from jimfb/cleanup-5151
Get rid of getNativeNode()
2 parents 102cd29 + 8eabf84 commit 067547c

8 files changed

+9
-42
lines changed

src/renderers/dom/shared/ReactDOMComponent.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,10 +1009,6 @@ ReactDOMComponent.Mixin = {
10091009
}
10101010
},
10111011

1012-
getNativeNode: function() {
1013-
return getNode(this);
1014-
},
1015-
10161012
/**
10171013
* Destroys all event registrations for this instance. Does not remove from
10181014
* the DOM. That must be done by the parent.
@@ -1057,13 +1053,15 @@ ReactDOMComponent.Mixin = {
10571053
break;
10581054
}
10591055

1056+
var nativeNode = getNode(this);
10601057
this.unmountChildren();
10611058
ReactDOMComponentTree.uncacheNode(this);
10621059
EventPluginHub.deleteAllListeners(this);
10631060
ReactComponentBrowserEnvironment.unmountIDFromEnvironment(this._rootNodeID);
10641061
this._rootNodeID = null;
10651062
this._domID = null;
10661063
this._wrapperState = null;
1064+
return nativeNode;
10671065
},
10681066

10691067
getPublicInstance: function() {

src/renderers/dom/shared/ReactDOMEmptyComponent.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,10 @@ assign(ReactDOMEmptyComponent.prototype, {
5757
},
5858
receiveComponent: function() {
5959
},
60-
getNativeNode: function() {
61-
return ReactDOMComponentTree.getNodeFromInstance(this);
62-
},
6360
unmountComponent: function() {
61+
var node = ReactDOMComponentTree.getNodeFromInstance(this);
6462
ReactDOMComponentTree.uncacheNode(this);
63+
return node;
6564
},
6665
});
6766

src/renderers/dom/shared/ReactDOMTextComponent.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,10 @@ assign(ReactDOMTextComponent.prototype, {
137137
}
138138
}
139139
},
140-
141-
getNativeNode: function() {
142-
return getNode(this);
143-
},
144-
145140
unmountComponent: function() {
141+
var node = getNode(this);
146142
ReactDOMComponentTree.uncacheNode(this);
143+
return node;
147144
},
148145

149146
});

src/renderers/shared/reconciler/ReactCompositeComponent.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,6 @@ var ReactCompositeComponentMixin = {
370370
return markup;
371371
},
372372

373-
getNativeNode: function() {
374-
return ReactReconciler.getNativeNode(this._renderedComponent);
375-
},
376-
377373
/**
378374
* Releases any resources allocated by `mountComponent`.
379375
*
@@ -388,7 +384,7 @@ var ReactCompositeComponentMixin = {
388384
}
389385

390386
if (this._renderedComponent) {
391-
ReactReconciler.unmountComponent(this._renderedComponent);
387+
var unmountedNativeNode = ReactReconciler.unmountComponent(this._renderedComponent);
392388
this._renderedNodeType = null;
393389
this._renderedComponent = null;
394390
this._instance = null;
@@ -419,6 +415,7 @@ var ReactCompositeComponentMixin = {
419415
// TODO: inst.props = null;
420416
// TODO: inst.state = null;
421417
// TODO: inst.context = null;
418+
return unmountedNativeNode;
422419
},
423420

424421
/**
@@ -806,15 +803,7 @@ var ReactCompositeComponentMixin = {
806803
this._processChildContext(context)
807804
);
808805
} else {
809-
// TODO: This is currently necessary due to the unfortunate caching
810-
// that ReactMount does which makes it exceedingly difficult to unmount
811-
// a set of siblings without accidentally repopulating the node cache (see
812-
// #5151). Once ReactMount no longer stores the nodes by ID, this method
813-
// can go away.
814-
var oldNativeNode = ReactReconciler.getNativeNode(prevComponentInstance);
815-
816-
ReactReconciler.unmountComponent(prevComponentInstance);
817-
806+
var oldNativeNode = ReactReconciler.unmountComponent(prevComponentInstance);
818807
this._renderedNodeType = ReactNodeTypes.getType(nextRenderedElement);
819808
this._renderedComponent = this._instantiateReactComponent(
820809
nextRenderedElement

src/renderers/shared/reconciler/ReactReconciler.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,6 @@ var ReactReconciler = {
5454
return markup;
5555
},
5656

57-
/**
58-
* Returns a value that can be passed to
59-
* ReactComponentEnvironment.replaceNodeWithMarkup.
60-
*/
61-
getNativeNode: function(internalInstance) {
62-
return internalInstance.getNativeNode();
63-
},
64-
6557
/**
6658
* Releases any resources allocated by `mountComponent`.
6759
*

src/renderers/shared/reconciler/ReactSimpleEmptyComponent.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ assign(ReactSimpleEmptyComponent.prototype, {
3838
},
3939
receiveComponent: function() {
4040
},
41-
getNativeNode: function() {
42-
return ReactReconciler.getNativeNode(this._renderedComponent);
43-
},
4441
unmountComponent: function() {
4542
ReactReconciler.unmountComponent(this._renderedComponent);
4643
this._renderedComponent = null;

src/renderers/shared/reconciler/instantiateReactComponent.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ function instantiateReactComponent(node) {
104104
typeof instance.construct === 'function' &&
105105
typeof instance.mountComponent === 'function' &&
106106
typeof instance.receiveComponent === 'function' &&
107-
typeof instance.getNativeNode === 'function' &&
108107
typeof instance.unmountComponent === 'function',
109108
'Only React Components can be mounted.'
110109
);

src/test/ReactTestUtils.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,10 +381,6 @@ NoopInternalComponent.prototype = {
381381
this._currentElement = element;
382382
},
383383

384-
getNativeNode: function() {
385-
return undefined;
386-
},
387-
388384
unmountComponent: function() {
389385
},
390386

0 commit comments

Comments
 (0)