Get rid of getNativeNode()
jim committed
Dec 17, 2015 at 19:03 UTC
8eabf842047a25cad91fad6f9231b3ad41ee31dd
8 files changed
+9
-42
src/renderers/dom/shared/ReactDOMComponent.js
+2
-4
@@ -996,10 +996,6 @@ ReactDOMComponent.Mixin = {
996
}
997
},
998
999
- getNativeNode: function() {
1000
- return getNode(this);
1001
- },
1002
-
999
/**
1000
* Destroys all event registrations for this instance. Does not remove from
1001
* the DOM. That must be done by the parent.
@@ -1044,6 +1040,7 @@ ReactDOMComponent.Mixin = {
1040
break;
1041
}
1042
1043
+ var nativeNode = getNode(this);
1044
this.unmountChildren();
1045
ReactDOMComponentTree.uncacheNode(this);
1046
EventPluginHub.deleteAllListeners(this);
@@ -1051,6 +1048,7 @@ ReactDOMComponent.Mixin = {
1048
this._rootNodeID = null;
1049
this._domID = null;
1050
this._wrapperState = null;
1051
+ return nativeNode;
1052
},
1053
1054
getPublicInstance: function() {
src/renderers/dom/shared/ReactDOMEmptyComponent.js
+2
-3
@@ -57,11 +57,10 @@ assign(ReactDOMEmptyComponent.prototype, {
57
},
58
receiveComponent: function() {
59
},
60
- getNativeNode: function() {
61
- return ReactDOMComponentTree.getNodeFromInstance(this);
62
- },
60
unmountComponent: function() {
61
+ var node = ReactDOMComponentTree.getNodeFromInstance(this);
62
ReactDOMComponentTree.uncacheNode(this);
63
+ return node;
64
},
65
});
66
src/renderers/dom/shared/ReactDOMTextComponent.js
+2
-5
@@ -137,13 +137,10 @@ assign(ReactDOMTextComponent.prototype, {
137
}
138
}
139
},
140
-
141
- getNativeNode: function() {
142
- return getNode(this);
143
- },
144
-
140
unmountComponent: function() {
141
+ var node = getNode(this);
142
ReactDOMComponentTree.uncacheNode(this);
143
+ return node;
144
},
145
146
});
src/renderers/shared/reconciler/ReactCompositeComponent.js
+3
-14
@@ -371,10 +371,6 @@ var ReactCompositeComponentMixin = {
371
return markup;
372
},
373
374
- getNativeNode: function() {
375
- return ReactReconciler.getNativeNode(this._renderedComponent);
376
- },
377
-
374
/**
375
* Releases any resources allocated by `mountComponent`.
376
*
@@ -389,7 +385,7 @@ var ReactCompositeComponentMixin = {
385
}
386
387
if (this._renderedComponent) {
392
- ReactReconciler.unmountComponent(this._renderedComponent);
388
+ var unmountedNativeNode = ReactReconciler.unmountComponent(this._renderedComponent);
389
this._renderedNodeType = null;
390
this._renderedComponent = null;
391
this._instance = null;
@@ -420,6 +416,7 @@ var ReactCompositeComponentMixin = {
416
// TODO: inst.props = null;
417
// TODO: inst.state = null;
418
// TODO: inst.context = null;
419
+ return unmountedNativeNode;
420
},
421
422
/**
@@ -807,15 +804,7 @@ var ReactCompositeComponentMixin = {
804
this._processChildContext(context)
805
);
806
} 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);
808
this._renderedNodeType = ReactNodeTypes.getType(nextRenderedElement);
809
this._renderedComponent = this._instantiateReactComponent(
810
nextRenderedElement
src/renderers/shared/reconciler/ReactReconciler.js
-8
@@ -54,14 +54,6 @@ var ReactReconciler = {
54
return markup;
55
},
56
57
- /**
58
- * Returns a value that can be passed to
59
- * ReactComponentEnvironment.replaceNodeWithMarkup.
60
- */
61
- getNativeNode: function(internalInstance) {
62
- return internalInstance.getNativeNode();
63
- },
64
-
57
/**
58
* Releases any resources allocated by `mountComponent`.
59
*
src/renderers/shared/reconciler/ReactSimpleEmptyComponent.js
-3
@@ -38,9 +38,6 @@ assign(ReactSimpleEmptyComponent.prototype, {
38
},
39
receiveComponent: function() {
40
},
41
- getNativeNode: function() {
42
- return ReactReconciler.getNativeNode(this._renderedComponent);
43
- },
41
unmountComponent: function() {
42
ReactReconciler.unmountComponent(this._renderedComponent);
43
this._renderedComponent = null;
src/renderers/shared/reconciler/instantiateReactComponent.js
-1
@@ -104,7 +104,6 @@ function instantiateReactComponent(node) {
104
typeof instance.construct === 'function' &&
105
typeof instance.mountComponent === 'function' &&
106
typeof instance.receiveComponent === 'function' &&
107
- typeof instance.getNativeNode === 'function' &&
107
typeof instance.unmountComponent === 'function',
108
'Only React Components can be mounted.'
109
);
src/test/ReactTestUtils.js
-4
@@ -381,10 +381,6 @@ NoopInternalComponent.prototype = {
381
this._currentElement = element;
382
},
383
384
- getNativeNode: function() {
385
- return undefined;
386
- },
387
-
384
unmountComponent: function() {
385
},
386