Skip to content

Commit

Permalink
Remove iterating through block parents
Browse files Browse the repository at this point in the history
  • Loading branch information
SantosGuillamot committed May 24, 2024
1 parent 3a26e71 commit 3ace0d9
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions packages/block-editor/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2512,23 +2512,7 @@ export function getBlockListSettings( state, clientId ) {
* @return {?Object} Block context of the block if set.
*/
export function getBlockContext( state, clientId ) {
let blockContext = { ...state.blockContext[ clientId ] };
// TODO: Review if it's necessary to get the context from the parent blocks.
getBlockParents( state, clientId ).forEach( ( parent ) => {
const block = getBlock( state, parent );
const blockType = getBlockType( block.name );
if ( blockType?.providesContext ) {
Object.keys( blockType.providesContext ).forEach(
( attributeName ) => {
blockContext = {
...blockContext,
[ attributeName ]: block.attributes[ attributeName ],
};
}
);
}
} );
return blockContext;
return state.blockContext[ clientId ];
}

/**
Expand Down

0 comments on commit 3ace0d9

Please sign in to comment.