Skip to content

Commit

Permalink
bring back the old behavior of cloneBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
marekhrabe committed Jul 31, 2019
1 parent 2b8f1fb commit 75f9bb0
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions packages/blocks/src/api/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,15 @@ export function createBlock( name, attributes = {}, innerBlocks = [] ) {
export function cloneBlock( block, mergeAttributes = {}, newInnerBlocks ) {
const clientId = uuid();

// Check for innerBlocks on block before attempting
// to map them. There are edge cases where they can
// be `undefined`
if ( ! newInnerBlocks && block.innerBlocks ) {
newInnerBlocks = block.innerBlocks.map( ( innerBlock ) => cloneBlock( innerBlock ) );
}

return {
...block,
clientId,
attributes: {
...block.attributes,
...mergeAttributes,
},
innerBlocks: newInnerBlocks,
innerBlocks: newInnerBlocks ||
block.innerBlocks.map( ( innerBlock ) => cloneBlock( innerBlock ) ),
};
}

Expand Down

0 comments on commit 75f9bb0

Please sign in to comment.