@samitouri / QOS-React-2 / commits / fb17e8ca56

Ensure that all internal instances have consistent properties

Use preventExtensions so that we can't add expando properties to internal instances. This ensures that the hidden class is kept more consistent.

Sebastian Markbage committed Nov 17, 2014 at 01:58 UTC fb17e8ca56a9b7688e7ccad7833d8a805ffc6ad5
5 files changed +21
src/browser/ui/ReactDOMComponent.js
+2
@@ -147,6 +147,8 @@ function validateDangerousTag(tag) {
147 function ReactDOMComponent(tag) {
148 validateDangerousTag(tag);
149 this._tag = tag;
150 + this._renderedChildren = null;
151 + this._previousStyleCopy = null;
152 }
153
154 ReactDOMComponent.displayName = 'ReactDOMComponent';
src/browser/ui/ReactDOMTextComponent.js
+4
@@ -50,6 +50,10 @@ assign(ReactDOMTextComponent.prototype, {
50 // TODO: This is really a ReactText (ReactNode), not a ReactElement
51 this._currentElement = text;
52 this._stringText = '' + text;
53 +
54 + // Properties
55 + this._rootNodeID = null;
56 + this._mountIndex = 0;
57 },
58
59 /**
src/core/ReactComponent.js
+4
@@ -118,6 +118,10 @@ var ReactComponent = {
118 // We keep the old element and a reference to the pending element
119 // to track updates.
120 this._currentElement = element;
121 +
122 + this._rootNodeID = null;
123 + this._mountIndex = 0;
124 + this._mountDepth = 0;
125 },
126
127 /**
src/core/ReactCompositeComponent.js
+3
@@ -117,8 +117,11 @@ var ReactCompositeComponentMixin = assign({},
117
118 this._pendingElement = null;
119 this._pendingState = null;
120 + this._pendingForceUpdate = false;
121 this._compositeLifeCycleState = null;
122
123 + this._renderedComponent = null;
124 +
125 // Children can be either an array or more than one argument
126 ReactComponent.Mixin.construct.apply(this, arguments);
127
src/core/instantiateReactComponent.js
+8
@@ -118,6 +118,14 @@ function instantiateReactComponent(node, parentCompositeType) {
118 // Sets up the instance. This can probably just move into the constructor now.
119 instance.construct(node);
120
121 + // Internal instances should fully constructed at this point, so they should
122 + // not get any new fields added to them at this point.
123 + if (__DEV__) {
124 + if (Object.preventExtensions) {
125 + Object.preventExtensions(instance);
126 + }
127 + }
128 +
129 return instance;
130 }
131