mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Improve DEV performance in Chrome (#7483)
* Ensure this._domID is always a number * Ensure this._rootNodeID is always a number
This commit is contained in:
@@ -81,7 +81,7 @@ function precacheChildNodes(inst, node) {
|
||||
}
|
||||
var childInst = children[name];
|
||||
var childID = getRenderedHostOrTextFromComponent(childInst)._domID;
|
||||
if (childID == null) {
|
||||
if (childID === 0) {
|
||||
// We're currently unmounting this child in ReactMultiChild; skip it.
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -488,8 +488,8 @@ function ReactDOMComponent(element) {
|
||||
this._previousStyleCopy = null;
|
||||
this._hostNode = null;
|
||||
this._hostParent = null;
|
||||
this._rootNodeID = null;
|
||||
this._domID = null;
|
||||
this._rootNodeID = 0;
|
||||
this._domID = 0;
|
||||
this._hostContainerInfo = null;
|
||||
this._wrapperState = null;
|
||||
this._topLevelWrapper = null;
|
||||
@@ -1190,8 +1190,8 @@ ReactDOMComponent.Mixin = {
|
||||
this.unmountChildren(safely);
|
||||
ReactDOMComponentTree.uncacheNode(this);
|
||||
EventPluginHub.deleteAllListeners(this);
|
||||
this._rootNodeID = null;
|
||||
this._domID = null;
|
||||
this._rootNodeID = 0;
|
||||
this._domID = 0;
|
||||
this._wrapperState = null;
|
||||
|
||||
if (__DEV__) {
|
||||
|
||||
@@ -22,7 +22,7 @@ var ReactDOMEmptyComponent = function(instantiate) {
|
||||
this._hostNode = null;
|
||||
this._hostParent = null;
|
||||
this._hostContainerInfo = null;
|
||||
this._domID = null;
|
||||
this._domID = 0;
|
||||
};
|
||||
Object.assign(ReactDOMEmptyComponent.prototype, {
|
||||
mountComponent: function(
|
||||
|
||||
@@ -43,7 +43,7 @@ var ReactDOMTextComponent = function(text) {
|
||||
this._hostParent = null;
|
||||
|
||||
// Properties
|
||||
this._domID = null;
|
||||
this._domID = 0;
|
||||
this._mountIndex = 0;
|
||||
this._closingComment = null;
|
||||
this._commentNodes = null;
|
||||
|
||||
@@ -634,7 +634,7 @@ describe('ReactDOMComponent', function() {
|
||||
|
||||
var NodeStub = function(initialProps) {
|
||||
this._currentElement = {props: initialProps};
|
||||
this._rootNodeID = 'test';
|
||||
this._rootNodeID = 1;
|
||||
};
|
||||
Object.assign(NodeStub.prototype, ReactDOMComponent.Mixin);
|
||||
|
||||
@@ -690,7 +690,7 @@ describe('ReactDOMComponent', function() {
|
||||
|
||||
var NodeStub = function(initialProps) {
|
||||
this._currentElement = {props: initialProps};
|
||||
this._rootNodeID = 'test';
|
||||
this._rootNodeID = 1;
|
||||
};
|
||||
Object.assign(NodeStub.prototype, ReactDOMComponent.Mixin);
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ ReactNativeBaseComponent.Mixin = {
|
||||
ReactNativeComponentTree.uncacheNode(this);
|
||||
deleteAllListeners(this);
|
||||
this.unmountChildren();
|
||||
this._rootNodeID = null;
|
||||
this._rootNodeID = 0;
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,7 +22,7 @@ var ReactNativeTextComponent = function(text) {
|
||||
this._currentElement = text;
|
||||
this._stringText = '' + text;
|
||||
this._hostParent = null;
|
||||
this._rootNodeID = null;
|
||||
this._rootNodeID = 0;
|
||||
};
|
||||
|
||||
Object.assign(ReactNativeTextComponent.prototype, {
|
||||
@@ -73,7 +73,7 @@ Object.assign(ReactNativeTextComponent.prototype, {
|
||||
ReactNativeComponentTree.uncacheNode(this);
|
||||
this._currentElement = null;
|
||||
this._stringText = null;
|
||||
this._rootNodeID = null;
|
||||
this._rootNodeID = 0;
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
@@ -33,7 +33,7 @@ var createReactNativeComponentClass = function(
|
||||
this._topLevelWrapper = null;
|
||||
this._hostParent = null;
|
||||
this._hostContainerInfo = null;
|
||||
this._rootNodeID = null;
|
||||
this._rootNodeID = 0;
|
||||
this._renderedChildren = null;
|
||||
};
|
||||
Constructor.displayName = viewConfig.uiViewClassName;
|
||||
|
||||
@@ -153,7 +153,7 @@ var ReactCompositeComponentMixin = {
|
||||
*/
|
||||
construct: function(element) {
|
||||
this._currentElement = element;
|
||||
this._rootNodeID = null;
|
||||
this._rootNodeID = 0;
|
||||
this._compositeType = null;
|
||||
this._instance = null;
|
||||
this._hostParent = null;
|
||||
@@ -612,7 +612,7 @@ var ReactCompositeComponentMixin = {
|
||||
// These fields do not really need to be reset since this object is no
|
||||
// longer accessible.
|
||||
this._context = null;
|
||||
this._rootNodeID = null;
|
||||
this._rootNodeID = 0;
|
||||
this._topLevelWrapper = null;
|
||||
|
||||
// Delete the reference from the instance to this internal representation
|
||||
|
||||
Reference in New Issue
Block a user