From 37ddfa0521d07c7066998704119ffaa249fa6aa8 Mon Sep 17 00:00:00 2001 From: CommitSyncScript Date: Tue, 18 Jun 2013 09:31:39 -0700 Subject: [PATCH] Don't transfer `children` in `transferPropsTo` 06cff60bc1eec13ff804af9f74b3b2b37b5490b3 made it so that `this.props.children` was no longer set when none were provided. var x =
; This caused an issue if the code was relying on the following not transferring children. return this.transferPropsTo(
); // this now transfer children --- src/core/ReactPropTransferer.js | 8 ++++-- ...actCompositeComponentTransferProps-test.js | 25 ++++++++++++++++--- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/core/ReactPropTransferer.js b/src/core/ReactPropTransferer.js index c1f697af4e..691ed58fc8 100644 --- a/src/core/ReactPropTransferer.js +++ b/src/core/ReactPropTransferer.js @@ -44,13 +44,17 @@ function createTransferStrategy(mergeStrategy) { */ var TransferStrategies = { /** - * Never transfer the `ref` prop. + * Never transfer `children`. */ - ref: emptyFunction, + children: emptyFunction, /** * Transfer the `className` prop by merging them. */ className: createTransferStrategy(joinClasses), + /** + * Never transfer the `ref` prop. + */ + ref: emptyFunction, /** * Transfer the `style` prop (which is an object) by merging them. */ diff --git a/src/core/__tests__/ReactCompositeComponentTransferProps-test.js b/src/core/__tests__/ReactCompositeComponentTransferProps-test.js index e32660801f..47cc7455af 100644 --- a/src/core/__tests__/ReactCompositeComponentTransferProps-test.js +++ b/src/core/__tests__/ReactCompositeComponentTransferProps-test.js @@ -51,7 +51,7 @@ describe('ReactCompositeComponent-transferProps', function() { ReactTestUtils.renderIntoDocument(instance); reactComponentExpect(instance) - .expectRenderedChild(instance) + .expectRenderedChild() .toBeDOMComponentWithTag('input') .scalarPropsEqual({ className: 'textinput', @@ -66,7 +66,7 @@ describe('ReactCompositeComponent-transferProps', function() { ReactTestUtils.renderIntoDocument(instance); reactComponentExpect(instance) - .expectRenderedChild(instance) + .expectRenderedChild() .toBeDOMComponentWithTag('input') .scalarPropsEqual({placeholder: 'Type here...'}); }); @@ -80,7 +80,7 @@ describe('ReactCompositeComponent-transferProps', function() { ReactTestUtils.renderIntoDocument(instance); reactComponentExpect(instance) - .expectRenderedChild(instance) + .expectRenderedChild() .toBeDOMComponentWithTag('input') .scalarPropsEqual({ className: 'textinput hidden_elem', @@ -91,6 +91,25 @@ describe('ReactCompositeComponent-transferProps', function() { }); }); + it('should not transfer children', function() { + var ChildrenTestComponent = React.createClass({ + render: function() { + return this.transferPropsTo(
); + } + }); + + var instance = + + Hello! + ; + + ReactTestUtils.renderIntoDocument(instance); + reactComponentExpect(instance) + .expectRenderedChild() + .toBeDOMComponentWithTag('div') + .toBeDOMComponentWithNoChildren(); + }); + it('should not transfer ref', function() { var RefTestComponent = React.createClass({ render: function() {