diff --git a/src/browser/ui/ReactDOMComponent.js b/src/browser/ui/ReactDOMComponent.js index 862e1af6a1..3bdae4cb36 100644 --- a/src/browser/ui/ReactDOMComponent.js +++ b/src/browser/ui/ReactDOMComponent.js @@ -173,8 +173,8 @@ ReactDOMComponent.Mixin = { transaction, mountDepth ); - assertValidProps(this.props); this._previousStyleCopy = null; + assertValidProps(this._currentElement.props); var closeTag = omittedCloseTags[this._tag] ? '' : ''; return ( this._createOpenTagMarkupAndPutListeners(transaction) + @@ -197,7 +197,7 @@ ReactDOMComponent.Mixin = { * @return {string} Markup of opening tag. */ _createOpenTagMarkupAndPutListeners: function(transaction) { - var props = this.props; + var props = this._currentElement.props; var ret = '<' + this._tag; for (var propKey in props) { @@ -253,16 +253,18 @@ ReactDOMComponent.Mixin = { prefix = '\n'; } + var props = this._currentElement.props; + // Intentional use of != to avoid catching zero/false. - var innerHTML = this.props.dangerouslySetInnerHTML; + var innerHTML = props.dangerouslySetInnerHTML; if (innerHTML != null) { if (innerHTML.__html != null) { return prefix + innerHTML.__html; } } else { var contentToUse = - CONTENT_TYPES[typeof this.props.children] ? this.props.children : null; - var childrenToUse = contentToUse != null ? null : this.props.children; + CONTENT_TYPES[typeof props.children] ? props.children : null; + var childrenToUse = contentToUse != null ? null : props.children; if (contentToUse != null) { return prefix + escapeTextForBrowser(contentToUse); } else if (childrenToUse != null) { @@ -338,7 +340,7 @@ ReactDOMComponent.Mixin = { * @param {ReactReconcileTransaction} transaction */ _updateDOMProperties: function(lastProps, transaction) { - var nextProps = this.props; + var nextProps = this._currentElement.props; var propKey; var styleName; var styleUpdates; @@ -427,7 +429,7 @@ ReactDOMComponent.Mixin = { * @param {ReactReconcileTransaction} transaction */ _updateDOMChildren: function(lastProps, transaction) { - var nextProps = this.props; + var nextProps = this._currentElement.props; var lastContent = CONTENT_TYPES[typeof lastProps.children] ? lastProps.children : null; diff --git a/src/browser/ui/__tests__/ReactDOMComponent-test.js b/src/browser/ui/__tests__/ReactDOMComponent-test.js index 3ab38722bf..58216c236e 100644 --- a/src/browser/ui/__tests__/ReactDOMComponent-test.js +++ b/src/browser/ui/__tests__/ReactDOMComponent-test.js @@ -226,7 +226,7 @@ describe('ReactDOMComponent', function() { var ReactReconcileTransaction = require('ReactReconcileTransaction'); var NodeStub = function(initialProps) { - this.props = initialProps || {}; + this._currentElement = { props: initialProps }; this._rootNodeID = 'test'; }; assign(NodeStub.prototype, ReactDOMComponent.Mixin); @@ -276,7 +276,7 @@ describe('ReactDOMComponent', function() { var ReactReconcileTransaction = require('ReactReconcileTransaction'); var NodeStub = function(initialProps) { - this.props = initialProps || {}; + this._currentElement = { props: initialProps }; this._rootNodeID = 'test'; }; assign(NodeStub.prototype, ReactDOMComponent.Mixin); diff --git a/src/core/ReactComponent.js b/src/core/ReactComponent.js index 896788db70..0e16b5b98c 100644 --- a/src/core/ReactComponent.js +++ b/src/core/ReactComponent.js @@ -225,10 +225,6 @@ var ReactComponent = { * @internal */ construct: function(element) { - // This is the public exposed props object after it has been processed - // with default props. The element's props represents the true internal - // state of the props. - this.props = element.props; // Record the component responsible for creating this component. // This is accessible through the element but we maintain an extra // field for compatibility with devtools and as a way to make an @@ -337,7 +333,6 @@ var ReactComponent = { var prevElement = this._currentElement; var nextElement = this._pendingElement; this._currentElement = nextElement; - this.props = nextElement.props; this._owner = nextElement._owner; this._pendingElement = null; this.updateComponent(transaction, prevElement, nextElement);