mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +00:00
Drop this.props
This commit is contained in:
1 parent
8181272fe8
commit
519ee322ca
3 files changed
+11
-14
No files matched your search
@@ -173,8 +173,8 @@ ReactDOMComponent.Mixin = {
|
||||
transaction,
|
||||
mountDepth
|
||||
);
|
||||
assertValidProps(this.props);
|
||||
this._previousStyleCopy = null;
|
||||
assertValidProps(this._currentElement.props);
|
||||
var closeTag = omittedCloseTags[this._tag] ? '' : '</' + 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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user