Skip to content

Commit 8eabf84

Browse files
committed
Get rid of getNativeNode()
1 parent 83328d4 commit 8eabf84

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
@@ -996,10 +996,6 @@ ReactDOMComponent.Mixin = {
996996
}
997997
},
998998

999-
getNativeNode: function() {
1000-
return getNode(this);
1001-
},
1002-
1003999
/**
10041000
* Destroys all event registrations for this instance. Does not remove from
10051001
* the DOM. That must be done by the parent.
@@ -1044,13 +1040,15 @@ ReactDOMComponent.Mixin = {
10441040
break;
10451041
}
10461042

1043+
var nativeNode = getNode(this);
10471044
this.unmountChildren();
10481045
ReactDOMComponentTree.uncacheNode(this);
10491046
EventPluginHub.deleteAllListeners(this);
10501047
ReactComponentBrowserEnvironment.unmountIDFromEnvironment(this._rootNodeID);
10511048
this._rootNodeID = null;
10521049
this._domID = null;
10531050
this._wrapperState = null;
1051+
return nativeNode;
10541052
},
10551053

10561054
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
@@ -371,10 +371,6 @@ var ReactCompositeComponentMixin = {
371371
return markup;
372372
},
373373

374-
getNativeNode: function() {
375-
return ReactReconciler.getNativeNode(this._renderedComponent);
376-
},
377-
378374
/**
379375
* Releases any resources allocated by `mountComponent`.
380376
*
@@ -389,7 +385,7 @@ var ReactCompositeComponentMixin = {
389385
}
390386

391387
if (this._renderedComponent) {
392-
ReactReconciler.unmountComponent(this._renderedComponent);
388+
var unmountedNativeNode = ReactReconciler.unmountComponent(this._renderedComponent);
393389
this._renderedNodeType = null;
394390
this._renderedComponent = null;
395391
this._instance = null;
@@ -420,6 +416,7 @@ var ReactCompositeComponentMixin = {
420416
// TODO: inst.props = null;
421417
// TODO: inst.state = null;
422418
// TODO: inst.context = null;
419+
return unmountedNativeNode;
423420
},
424421

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