@samitouri / QOS-React / commits / 4b734f7a02

Improve DEV performance in Chrome (#7483)

* Ensure this._domID is always a number * Ensure this._rootNodeID is always a number

Dan Abramov committed Aug 12, 2016 at 18:34 UTC 4b734f7a025c828be8c5d85f7c8d88679ae8f952
9 files changed +15 -15
src/renderers/dom/client/ReactDOMComponentTree.js
+1 -1
@@ -81,7 +81,7 @@ function precacheChildNodes(inst, node) {
81 }
82 var childInst = children[name];
83 var childID = getRenderedHostOrTextFromComponent(childInst)._domID;
84 - if (childID == null) {
84 + if (childID === 0) {
85 // We're currently unmounting this child in ReactMultiChild; skip it.
86 continue;
87 }
src/renderers/dom/shared/ReactDOMComponent.js
+4 -4
@@ -488,8 +488,8 @@ function ReactDOMComponent(element) {
488 this._previousStyleCopy = null;
489 this._hostNode = null;
490 this._hostParent = null;
491 - this._rootNodeID = null;
492 - this._domID = null;
491 + this._rootNodeID = 0;
492 + this._domID = 0;
493 this._hostContainerInfo = null;
494 this._wrapperState = null;
495 this._topLevelWrapper = null;
@@ -1190,8 +1190,8 @@ ReactDOMComponent.Mixin = {
1190 this.unmountChildren(safely);
1191 ReactDOMComponentTree.uncacheNode(this);
1192 EventPluginHub.deleteAllListeners(this);
1193 - this._rootNodeID = null;
1194 - this._domID = null;
1193 + this._rootNodeID = 0;
1194 + this._domID = 0;
1195 this._wrapperState = null;
1196
1197 if (__DEV__) {
src/renderers/dom/shared/ReactDOMEmptyComponent.js
+1 -1
@@ -22,7 +22,7 @@ var ReactDOMEmptyComponent = function(instantiate) {
22 this._hostNode = null;
23 this._hostParent = null;
24 this._hostContainerInfo = null;
25 - this._domID = null;
25 + this._domID = 0;
26 };
27 Object.assign(ReactDOMEmptyComponent.prototype, {
28 mountComponent: function(
src/renderers/dom/shared/ReactDOMTextComponent.js
+1 -1
@@ -43,7 +43,7 @@ var ReactDOMTextComponent = function(text) {
43 this._hostParent = null;
44
45 // Properties
46 - this._domID = null;
46 + this._domID = 0;
47 this._mountIndex = 0;
48 this._closingComment = null;
49 this._commentNodes = null;
src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
+2 -2
@@ -634,7 +634,7 @@ describe('ReactDOMComponent', function() {
634
635 var NodeStub = function(initialProps) {
636 this._currentElement = {props: initialProps};
637 - this._rootNodeID = 'test';
637 + this._rootNodeID = 1;
638 };
639 Object.assign(NodeStub.prototype, ReactDOMComponent.Mixin);
640
@@ -690,7 +690,7 @@ describe('ReactDOMComponent', function() {
690
691 var NodeStub = function(initialProps) {
692 this._currentElement = {props: initialProps};
693 - this._rootNodeID = 'test';
693 + this._rootNodeID = 1;
694 };
695 Object.assign(NodeStub.prototype, ReactDOMComponent.Mixin);
696
src/renderers/native/ReactNativeBaseComponent.js
+1 -1
@@ -59,7 +59,7 @@ ReactNativeBaseComponent.Mixin = {
59 ReactNativeComponentTree.uncacheNode(this);
60 deleteAllListeners(this);
61 this.unmountChildren();
62 - this._rootNodeID = null;
62 + this._rootNodeID = 0;
63 },
64
65 /**
src/renderers/native/ReactNativeTextComponent.js
+2 -2
@@ -22,7 +22,7 @@ var ReactNativeTextComponent = function(text) {
22 this._currentElement = text;
23 this._stringText = '' + text;
24 this._hostParent = null;
25 - this._rootNodeID = null;
25 + this._rootNodeID = 0;
26 };
27
28 Object.assign(ReactNativeTextComponent.prototype, {
@@ -73,7 +73,7 @@ Object.assign(ReactNativeTextComponent.prototype, {
73 ReactNativeComponentTree.uncacheNode(this);
74 this._currentElement = null;
75 this._stringText = null;
76 - this._rootNodeID = null;
76 + this._rootNodeID = 0;
77 },
78
79 });
src/renderers/native/createReactNativeComponentClass.js
+1 -1
@@ -33,7 +33,7 @@ var createReactNativeComponentClass = function(
33 this._topLevelWrapper = null;
34 this._hostParent = null;
35 this._hostContainerInfo = null;
36 - this._rootNodeID = null;
36 + this._rootNodeID = 0;
37 this._renderedChildren = null;
38 };
39 Constructor.displayName = viewConfig.uiViewClassName;
src/renderers/shared/stack/reconciler/ReactCompositeComponent.js
+2 -2
@@ -153,7 +153,7 @@ var ReactCompositeComponentMixin = {
153 */
154 construct: function(element) {
155 this._currentElement = element;
156 - this._rootNodeID = null;
156 + this._rootNodeID = 0;
157 this._compositeType = null;
158 this._instance = null;
159 this._hostParent = null;
@@ -612,7 +612,7 @@ var ReactCompositeComponentMixin = {
612 // These fields do not really need to be reset since this object is no
613 // longer accessible.
614 this._context = null;
615 - this._rootNodeID = null;
615 + this._rootNodeID = 0;
616 this._topLevelWrapper = null;
617
618 // Delete the reference from the instance to this internal representation