Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions examples/jquery-bootstrap/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
// Bootstrap's classes
var BootstrapButton = React.createClass({
render: function() {
// transferPropsTo() is smart enough to merge classes provided
// to this component.
return this.transferPropsTo(
<a href="javascript:;" role="button" className="btn">
{this.props.children}
</a>
return (
<a {...this.props}
href="javascript:;"
role="button"
className={(this.props.className || '') + ' btn'} />
);
}
});
Expand Down
8 changes: 6 additions & 2 deletions examples/jquery-mobile/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,15 @@ var JQueryMobilePage = React.createClass({
},

render: function() {
return this.transferPropsTo(React.DOM.div(null,
var props = {};
for (var key in this.props) {
props[key] = this.props[key];
}
return React.DOM.div(props,
JQueryMobileHeader({title:'Page ' + this.props.id, headerTheme:this.props.headerTheme}),
JQueryMobileContent(null, this.props.children),
JQueryMobileFooter(null)
));
);
}
});

Expand Down
12 changes: 9 additions & 3 deletions perf/lib/todolist.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,14 @@ todolist.NewItemForm = React.createClass({
return false;
},
render: function(){
return this.transferPropsTo(
React.DOM.input({ref:"text", onKeyDown:this.props.onEnter && this._handleNewItemKeyDown})
);
var props = {};
for (var key in this.props) {
if (key !== "onEnter") {
props[key] = this.props[key];
}
}
props.ref = "text";
props.onKeyDown = this.props.onEnter && this._handleNewItemKeyDown;
return React.DOM.input(props);
}
});
3 changes: 0 additions & 3 deletions src/class/ReactClass.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
var ReactElement = require('ReactElement');
var ReactErrorUtils = require('ReactErrorUtils');
var ReactInstanceMap = require('ReactInstanceMap');
var ReactPropTransferer = require('ReactPropTransferer');
var ReactPropTypeLocations = require('ReactPropTypeLocations');
var ReactPropTypeLocationNames = require('ReactPropTypeLocationNames');

Expand Down Expand Up @@ -826,15 +825,13 @@ var ReactClassMixin = {
var ReactClassBase = function() {};
assign(
ReactClassBase.prototype,
ReactPropTransferer.Mixin,
ReactClassMixin
);

/**
* Module for creating composite components.
*
* @class ReactClass
* @extends ReactPropTransferer
*/
var ReactClass = {

Expand Down
51 changes: 0 additions & 51 deletions src/core/ReactPropTransferer.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ function transferInto(props, newProps) {
*/
var ReactPropTransferer = {

TransferStrategies: TransferStrategies,

/**
* Merge two props objects using TransferStrategies.
*
Expand All @@ -109,55 +107,6 @@ var ReactPropTransferer = {
return transferInto(assign({}, oldProps), newProps);
},

/**
* @lends {ReactPropTransferer.prototype}
*/
Mixin: {

/**
* Transfer props from this component to a target component.
*
* Props that do not have an explicit transfer strategy will be transferred
* only if the target component does not already have the prop set.
*
* This is usually used to pass down props to a returned root component.
*
* @param {ReactElement} element Component receiving the properties.
* @return {ReactElement} The supplied `component`.
* @final
* @protected
*/
transferPropsTo: function(element) {
invariant(
element._owner && element._owner.getPublicInstance() === this,
'%s: You can\'t call transferPropsTo() on a component that you ' +
'don\'t own, %s. This usually means you are calling ' +
'transferPropsTo() on a component passed in as props or children.',
this.constructor.displayName,
typeof element.type === 'string' ?
element.type :
element.type.displayName
);

if (__DEV__) {
if (!didWarn) {
didWarn = true;
warning(
false,
'transferPropsTo is deprecated. ' +
'See http://fb.me/react-transferpropsto for more information.'
);
}
}

// Because elements are immutable we have to merge into the existing
// props object rather than clone it.
transferInto(element.props, this.props);

return element;
}

}
};

module.exports = ReactPropTransferer;
188 changes: 0 additions & 188 deletions src/core/__tests__/ReactPropTransferer-test.js

This file was deleted.

4 changes: 2 additions & 2 deletions src/utils/cloneWithProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ var CHILDREN_PROP = keyOf({children: null});
* this is to add a CSS class.
*
* @param {object} child child component you'd like to clone
* @param {object} props props you'd like to modify. They will be merged
* as if you used `transferPropsTo()`.
* @param {object} props props you'd like to modify. className and style will be
* merged automatically.
* @return {object} a clone of child with props merged in.
*/
function cloneWithProps(child, props) {
Expand Down