diff --git a/src/renderers/dom/shared/ReactDOMComponent.js b/src/renderers/dom/shared/ReactDOMComponent.js index 6221f05c95..ae3f783eb7 100644 --- a/src/renderers/dom/shared/ReactDOMComponent.js +++ b/src/renderers/dom/shared/ReactDOMComponent.js @@ -405,8 +405,10 @@ var globalIdCounter = 1; * @constructor ReactDOMComponent * @extends ReactMultiChild */ -function ReactDOMComponent(tag) { +function ReactDOMComponent(element) { + var tag = element.type; validateDangerousTag(tag); + this._currentElement = element; this._tag = tag.toLowerCase(); this._namespaceURI = null; this._renderedChildren = null; @@ -429,10 +431,6 @@ ReactDOMComponent.displayName = 'ReactDOMComponent'; ReactDOMComponent.Mixin = { - construct: function(element) { - this._currentElement = element; - }, - /** * Generates root tag markup then recurses. This method has side effects and * is not idempotent. diff --git a/src/renderers/dom/shared/ReactDOMEmptyComponent.js b/src/renderers/dom/shared/ReactDOMEmptyComponent.js index e07c44781e..c15ec123d6 100644 --- a/src/renderers/dom/shared/ReactDOMEmptyComponent.js +++ b/src/renderers/dom/shared/ReactDOMEmptyComponent.js @@ -26,8 +26,6 @@ var ReactDOMEmptyComponent = function(instantiate) { this._domID = null; }; assign(ReactDOMEmptyComponent.prototype, { - construct: function(element) { - }, mountComponent: function( transaction, nativeParent, diff --git a/src/renderers/dom/shared/ReactDOMTextComponent.js b/src/renderers/dom/shared/ReactDOMTextComponent.js index 63d022bf33..b145ede10e 100644 --- a/src/renderers/dom/shared/ReactDOMTextComponent.js +++ b/src/renderers/dom/shared/ReactDOMTextComponent.js @@ -38,29 +38,21 @@ var getNode = ReactDOMComponentTree.getNodeFromInstance; * @extends ReactComponent * @internal */ -var ReactDOMTextComponent = function(props) { - // This constructor and its argument is currently used by mocks. +var ReactDOMTextComponent = function(text) { + // TODO: This is really a ReactText (ReactNode), not a ReactElement + this._currentElement = text; + this._stringText = '' + text; + // ReactDOMComponentTree uses these: + this._nativeNode = null; + this._nativeParent = null; + + // Properties + this._domID = null; + this._mountIndex = 0; }; assign(ReactDOMTextComponent.prototype, { - /** - * @param {ReactText} text - * @internal - */ - construct: function(text) { - // TODO: This is really a ReactText (ReactNode), not a ReactElement - this._currentElement = text; - this._stringText = '' + text; - // ReactDOMComponentTree uses these: - this._nativeNode = null; - this._nativeParent = null; - - // Properties - this._domID = null; - this._mountIndex = 0; - }, - /** * Creates the markup for this text node. This node is not intended to have * any features besides containing text content. diff --git a/src/renderers/shared/reconciler/ReactNativeComponent.js b/src/renderers/shared/reconciler/ReactNativeComponent.js index 503b4af0a2..42fe1108a5 100644 --- a/src/renderers/shared/reconciler/ReactNativeComponent.js +++ b/src/renderers/shared/reconciler/ReactNativeComponent.js @@ -68,7 +68,7 @@ function createInternalComponent(element) { 'There is no registered component for the tag %s', element.type ); - return new genericComponentClass(element.type, element.props); + return new genericComponentClass(element); } /** diff --git a/src/renderers/shared/reconciler/ReactSimpleEmptyComponent.js b/src/renderers/shared/reconciler/ReactSimpleEmptyComponent.js index 2a886be3be..e38fdcb7ca 100644 --- a/src/renderers/shared/reconciler/ReactSimpleEmptyComponent.js +++ b/src/renderers/shared/reconciler/ReactSimpleEmptyComponent.js @@ -20,8 +20,6 @@ var ReactSimpleEmptyComponent = function(placeholderElement, instantiate) { this._renderedComponent = instantiate(placeholderElement); }; assign(ReactSimpleEmptyComponent.prototype, { - construct: function(element) { - }, mountComponent: function( transaction, nativeParent, diff --git a/src/renderers/shared/reconciler/instantiateReactComponent.js b/src/renderers/shared/reconciler/instantiateReactComponent.js index 4ddf8e861f..cb0208f92a 100644 --- a/src/renderers/shared/reconciler/instantiateReactComponent.js +++ b/src/renderers/shared/reconciler/instantiateReactComponent.js @@ -20,7 +20,9 @@ var invariant = require('invariant'); var warning = require('warning'); // To avoid a cyclic dependency, we create the final class in this module -var ReactCompositeComponentWrapper = function() { }; +var ReactCompositeComponentWrapper = function(element) { + this.construct(element); +}; assign( ReactCompositeComponentWrapper.prototype, ReactCompositeComponent.Mixin, @@ -87,7 +89,7 @@ function instantiateReactComponent(node) { // representation, we can drop this code path. instance = new element.type(element); } else { - instance = new ReactCompositeComponentWrapper(); + instance = new ReactCompositeComponentWrapper(element); } } else if (typeof node === 'string' || typeof node === 'number') { instance = ReactNativeComponent.createInstanceForText(node); @@ -101,7 +103,6 @@ function instantiateReactComponent(node) { if (__DEV__) { warning( - typeof instance.construct === 'function' && typeof instance.mountComponent === 'function' && typeof instance.receiveComponent === 'function' && typeof instance.getNativeNode === 'function' && @@ -110,9 +111,6 @@ function instantiateReactComponent(node) { ); } - // Sets up the instance. This can probably just move into the constructor now. - instance.construct(node); - // These two fields are used by the DOM and ART diffing algorithms // respectively. Instead of using expandos on components, we should be // storing the state needed by the diffing algorithms elsewhere. diff --git a/src/test/ReactTestUtils.js b/src/test/ReactTestUtils.js index 04ab62dbf7..182a7aa906 100644 --- a/src/test/ReactTestUtils.js +++ b/src/test/ReactTestUtils.js @@ -393,7 +393,9 @@ NoopInternalComponent.prototype = { }, }; -var ShallowComponentWrapper = function() { }; +var ShallowComponentWrapper = function(element) { + this.construct(element); +}; assign( ShallowComponentWrapper.prototype, ReactCompositeComponent.Mixin, { @@ -457,10 +459,7 @@ ReactShallowRenderer.prototype._render = function(element, transaction, context) this._instance.receiveComponent(element, transaction, context); } else { var instance = new ShallowComponentWrapper(element.type); - instance.construct(element); - instance.mountComponent(transaction, null, null, context); - this._instance = instance; } };