Skip to content
Closed
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
Unset keys when concatenating child elements
  • Loading branch information
aduth committed May 3, 2017
commit 6547d7ffcb19eafe4ef4799e59dc8fe66558efaa
6 changes: 3 additions & 3 deletions element/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ export function renderToString( element ) {
* @return {Array} The concatenated value
*/
export function concatChildren( ...childrens ) {
return childrens.reduce( ( memo, children, i ) => {
Children.forEach( children, ( child, j ) => {
return childrens.reduce( ( memo, children ) => {
Children.forEach( children, ( child ) => {
if ( child && 'string' !== typeof child ) {
child = cloneElement( child, {
key: [ i, j ].join()
key: undefined
} );
}

Expand Down
6 changes: 3 additions & 3 deletions element/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ describe( 'element', () => {
expect( concatChildren( [ 'a' ], 'b' ) ).to.eql( [ 'a', 'b' ] );
} );

it( 'should concat the object arrays and rewrite keys', () => {
it( 'should concat the object arrays and unset keys', () => {
const concat = concatChildren(
[ createElement( 'strong', {}, 'Courgette' ) ],
createElement( 'strong', {}, 'Concombre' )
);
expect( concat.length ).to.equal( 2 );
expect( concat[ 0 ].key ).to.equal( '0,0' );
expect( concat[ 1 ].key ).to.equal( '1,0' );
expect( concat[ 0 ].key ).to.be.null();
expect( concat[ 1 ].key ).to.be.null();
} );
} );
} );