mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
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.
This commit is contained in:
@@ -147,6 +147,8 @@ function validateDangerousTag(tag) {
|
||||
function ReactDOMComponent(tag) {
|
||||
validateDangerousTag(tag);
|
||||
this._tag = tag;
|
||||
this._renderedChildren = null;
|
||||
this._previousStyleCopy = null;
|
||||
}
|
||||
|
||||
ReactDOMComponent.displayName = 'ReactDOMComponent';
|
||||
|
||||
@@ -50,6 +50,10 @@ assign(ReactDOMTextComponent.prototype, {
|
||||
// TODO: This is really a ReactText (ReactNode), not a ReactElement
|
||||
this._currentElement = text;
|
||||
this._stringText = '' + text;
|
||||
|
||||
// Properties
|
||||
this._rootNodeID = null;
|
||||
this._mountIndex = 0;
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -118,6 +118,10 @@ var ReactComponent = {
|
||||
// We keep the old element and a reference to the pending element
|
||||
// to track updates.
|
||||
this._currentElement = element;
|
||||
|
||||
this._rootNodeID = null;
|
||||
this._mountIndex = 0;
|
||||
this._mountDepth = 0;
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -117,8 +117,11 @@ var ReactCompositeComponentMixin = assign({},
|
||||
|
||||
this._pendingElement = null;
|
||||
this._pendingState = null;
|
||||
this._pendingForceUpdate = false;
|
||||
this._compositeLifeCycleState = null;
|
||||
|
||||
this._renderedComponent = null;
|
||||
|
||||
// Children can be either an array or more than one argument
|
||||
ReactComponent.Mixin.construct.apply(this, arguments);
|
||||
|
||||
|
||||
@@ -118,6 +118,14 @@ function instantiateReactComponent(node, parentCompositeType) {
|
||||
// Sets up the instance. This can probably just move into the constructor now.
|
||||
instance.construct(node);
|
||||
|
||||
// Internal instances should fully constructed at this point, so they should
|
||||
// not get any new fields added to them at this point.
|
||||
if (__DEV__) {
|
||||
if (Object.preventExtensions) {
|
||||
Object.preventExtensions(instance);
|
||||
}
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user