The library for web and native user interfaces.
Don't transfer `children` in `transferPropsTo`
06cff60bc1eec13ff804af9f74b3b2b37b5490b3 made it so that `this.props.children` was no longer set when none were provided. var x = <div />; This caused an issue if the code was relying on the following not transferring children. return this.transferPropsTo(<div />); // this now transfer children
CommitSyncScript committed
Jun 18, 2013 at 09:31 UTC
37ddfa0521d07c7066998704119ffaa249fa6aa8
2 files changed
+28
-5
src/core/ReactPropTransferer.js
+6
-2
@@ -44,13 +44,17 @@ function createTransferStrategy(mergeStrategy) {
44
*/
45
var TransferStrategies = {
46
/**
47
- * Never transfer the `ref` prop.
47
+ * Never transfer `children`.
48
*/
49
- ref: emptyFunction,
49
+ children: emptyFunction,
50
/**
51
* Transfer the `className` prop by merging them.
52
*/
53
className: createTransferStrategy(joinClasses),
54
+ /**
55
+ * Never transfer the `ref` prop.
56
+ */
57
+ ref: emptyFunction,
58
/**
59
* Transfer the `style` prop (which is an object) by merging them.
60
*/
src/core/__tests__/ReactCompositeComponentTransferProps-test.js
+22
-3
@@ -51,7 +51,7 @@ describe('ReactCompositeComponent-transferProps', function() {
51
ReactTestUtils.renderIntoDocument(instance);
52
53
reactComponentExpect(instance)
54
- .expectRenderedChild(instance)
54
+ .expectRenderedChild()
55
.toBeDOMComponentWithTag('input')
56
.scalarPropsEqual({
57
className: 'textinput',
@@ -66,7 +66,7 @@ describe('ReactCompositeComponent-transferProps', function() {
66
ReactTestUtils.renderIntoDocument(instance);
67
68
reactComponentExpect(instance)
69
- .expectRenderedChild(instance)
69
+ .expectRenderedChild()
70
.toBeDOMComponentWithTag('input')
71
.scalarPropsEqual({placeholder: 'Type here...'});
72
});
@@ -80,7 +80,7 @@ describe('ReactCompositeComponent-transferProps', function() {
80
ReactTestUtils.renderIntoDocument(instance);
81
82
reactComponentExpect(instance)
83
- .expectRenderedChild(instance)
83
+ .expectRenderedChild()
84
.toBeDOMComponentWithTag('input')
85
.scalarPropsEqual({
86
className: 'textinput hidden_elem',
@@ -91,6 +91,25 @@ describe('ReactCompositeComponent-transferProps', function() {
91
});
92
});
93
94
+ it('should not transfer children', function() {
95
+ var ChildrenTestComponent = React.createClass({
96
+ render: function() {
97
+ return this.transferPropsTo(<div />);
98
+ }
99
+ });
100
+
101
+ var instance =
102
+ <ChildrenTestComponent>
103
+ <span>Hello!</span>
104
+ </ChildrenTestComponent>;
105
+
106
+ ReactTestUtils.renderIntoDocument(instance);
107
+ reactComponentExpect(instance)
108
+ .expectRenderedChild()
109
+ .toBeDOMComponentWithTag('div')
110
+ .toBeDOMComponentWithNoChildren();
111
+ });
112
+
113
it('should not transfer ref', function() {
114
var RefTestComponent = React.createClass({
115
render: function() {