From 1302edba5ee93d1fd8cf252bea8b75e1bc66a838 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Tue, 24 Sep 2024 08:52:52 -0700 Subject: [PATCH] Blocks: Don't memoize 'hasContentRoleAttribute' selector (#65617) Co-authored-by: Mamaduka Co-authored-by: youknowriad Co-authored-by: tyxla Co-authored-by: jsnajdr Co-authored-by: getdave --- .../blocks/src/store/private-selectors.js | 49 +++++++++---------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/packages/blocks/src/store/private-selectors.js b/packages/blocks/src/store/private-selectors.js index 81bdc1fca2c420..d5665323859e40 100644 --- a/packages/blocks/src/store/private-selectors.js +++ b/packages/blocks/src/store/private-selectors.js @@ -219,32 +219,27 @@ export function getBlockBindingsSource( state, sourceName ) { * @param {string} blockTypeName Block type name. * @return {boolean} Whether block type has content role attribute. */ -export const hasContentRoleAttribute = createSelector( - ( state, blockTypeName ) => { - const blockType = getBlockType( state, blockTypeName ); - if ( ! blockType ) { +export const hasContentRoleAttribute = ( state, blockTypeName ) => { + const blockType = getBlockType( state, blockTypeName ); + if ( ! blockType ) { + return false; + } + + return Object.values( blockType.attributes ).some( + ( { role, __experimentalRole } ) => { + if ( role === 'content' ) { + return true; + } + if ( __experimentalRole === 'content' ) { + deprecated( '__experimentalRole attribute', { + since: '6.7', + version: '6.8', + alternative: 'role attribute', + hint: `Check the block.json of the ${ blockTypeName } block.`, + } ); + return true; + } return false; } - - return Object.entries( blockType.attributes ).some( - ( [ , { role, __experimentalRole } ] ) => { - if ( role === 'content' ) { - return true; - } - if ( __experimentalRole === 'content' ) { - deprecated( '__experimentalRole attribute', { - since: '6.7', - version: '6.8', - alternative: 'role attribute', - hint: `Check the block.json of the ${ blockTypeName } block.`, - } ); - return true; - } - return false; - } - ); - }, - ( state, blockTypeName ) => [ - state.blockTypes[ blockTypeName ]?.attributes, - ] -); + ); +};