Skip to content

Commit

Permalink
Improve DEV performance in Chrome (#7483)
Browse files Browse the repository at this point in the history
* Ensure this._domID is always a number

* Ensure this._rootNodeID is always a number

(cherry picked from commit 4b734f7)
  • Loading branch information
gaearon authored and zpao committed Aug 12, 2016
1 parent c93d0c4 commit 6a99238
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/renderers/dom/client/ReactDOMComponentTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions src/renderers/dom/shared/ReactDOMComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,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;
Expand Down Expand Up @@ -1179,8 +1179,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__) {
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/dom/shared/ReactDOMEmptyComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/dom/shared/ReactDOMTextComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ describe('ReactDOMComponent', function() {

var NodeStub = function(initialProps) {
this._currentElement = {props: initialProps};
this._rootNodeID = 'test';
this._rootNodeID = 1;
};
Object.assign(NodeStub.prototype, ReactDOMComponent.Mixin);

Expand Down Expand Up @@ -731,7 +731,7 @@ describe('ReactDOMComponent', function() {

var NodeStub = function(initialProps) {
this._currentElement = {props: initialProps};
this._rootNodeID = 'test';
this._rootNodeID = 1;
};
Object.assign(NodeStub.prototype, ReactDOMComponent.Mixin);

Expand Down
2 changes: 1 addition & 1 deletion src/renderers/native/ReactNativeBaseComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ ReactNativeBaseComponent.Mixin = {
ReactNativeComponentTree.uncacheNode(this);
deleteAllListeners(this);
this.unmountChildren();
this._rootNodeID = null;
this._rootNodeID = 0;
},

/**
Expand Down
4 changes: 2 additions & 2 deletions src/renderers/native/ReactNativeTextComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down Expand Up @@ -73,7 +73,7 @@ Object.assign(ReactNativeTextComponent.prototype, {
ReactNativeComponentTree.uncacheNode(this);
this._currentElement = null;
this._stringText = null;
this._rootNodeID = null;
this._rootNodeID = 0;
},

});
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/native/createReactNativeComponentClass.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ var ReactCompositeComponentMixin = {
*/
construct: function(element) {
this._currentElement = element;
this._rootNodeID = null;
this._rootNodeID = 0;
this._compositeType = null;
this._instance = null;
this._hostParent = null;
Expand Down Expand Up @@ -609,7 +609,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
Expand Down

0 comments on commit 6a99238

Please sign in to comment.