Skip to content

Commit

Permalink
Blocks: Don't memoize 'hasContentRoleAttribute' selector (#65617)
Browse files Browse the repository at this point in the history
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: youknowriad <[email protected]>
Co-authored-by: tyxla <[email protected]>
Co-authored-by: jsnajdr <[email protected]>
Co-authored-by: getdave <[email protected]>
  • Loading branch information
6 people authored and noisysocks committed Sep 30, 2024
1 parent cd0974a commit fdd69d5
Showing 1 changed file with 22 additions and 27 deletions.
49 changes: 22 additions & 27 deletions packages/blocks/src/store/private-selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]
);
);
};

1 comment on commit fdd69d5

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in fdd69d5.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11097441556
📝 Reported issues:

Please sign in to comment.