Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ockham committed Nov 10, 2017
1 parent 0a15d73 commit 850c06d
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/index.es6
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,17 @@ function buildChildren( tokens, components ) {
break;
}
// componentSelfClosing token
children.push( components[ token.value ] );
if ( components[ token.value ] ) {
children.push( React.cloneElement( components[ token.value ], { key: i } ) );
}
continue;
}

if ( openComponent ) {
closeIndex = getCloseIndex( openIndex, tokens );
grandChildTokens = tokens.slice( ( openIndex + 1 ), closeIndex );
grandChildren = buildChildren( grandChildTokens, components );
clonedOpenComponent = React.cloneElement( openComponent, {}, grandChildren );
clonedOpenComponent = React.cloneElement( openComponent, { key: openIndex }, grandChildren );
children.push( clonedOpenComponent );

if ( closeIndex < tokens.length - 1 ) {
Expand All @@ -83,17 +85,7 @@ function buildChildren( tokens, components ) {
return children[ 0 ];
}

return children.map( ( child, index ) => {
if ( child ) {
return React.cloneElement(
child,
{ key: `interpolation-child-${ index }` },
child.props !== undefined
? child.props.children
: undefined
);
}
} );
return children;
}

function interpolate( options ) {
Expand Down

0 comments on commit 850c06d

Please sign in to comment.