Skip to content

Commit

Permalink
Blocks: Remove client-side polyfill for 'selectors' (#60846)
Browse files Browse the repository at this point in the history
* Blocks: Remove client-side polyfill for 'selectors'
* Remove polyfill's unit test

Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
  • Loading branch information
3 people committed Apr 18, 2024
1 parent 8029450 commit 62198d2
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 50 deletions.
37 changes: 0 additions & 37 deletions packages/blocks/src/api/test/registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,43 +398,6 @@ describe( 'blocks', () => {
} );
} );

// This can be removed once polyfill adding selectors has been removed.
it( 'should apply selectors on the client when not set on the server', () => {
const blockName = 'core/test-block-with-selectors';
unstable__bootstrapServerSideBlockDefinitions( {
[ blockName ]: {
category: 'widgets',
},
} );
unstable__bootstrapServerSideBlockDefinitions( {
[ blockName ]: {
selectors: { root: '.wp-block-custom-selector' },
category: 'ignored',
},
} );

const blockType = {
title: 'block title',
};
registerBlockType( blockName, blockType );
expect( getBlockType( blockName ) ).toEqual( {
name: blockName,
save: expect.any( Function ),
title: 'block title',
category: 'widgets',
icon: { src: BLOCK_ICON_DEFAULT },
attributes: {},
providesContext: {},
usesContext: [],
keywords: [],
selectors: { root: '.wp-block-custom-selector' },
supports: {},
styles: [],
variations: [],
blockHooks: {},
} );
} );

// This test can be removed once the polyfill for blockHooks gets removed.
it( 'should polyfill blockHooks using metadata on the client when not set on the server', () => {
const blockName = 'tests/hooked-block';
Expand Down
13 changes: 0 additions & 13 deletions packages/blocks/src/store/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,6 @@ function bootstrappedBlockTypes( state = {}, action ) {
// Don't overwrite if already set. It covers the case when metadata
// was initialized from the server.
if ( serverDefinition ) {
// The `selectors` prop is not yet included in the server provided
// definitions and needs to be polyfilled. This can be removed when the
// minimum supported WordPress is >= 6.3.
if (
serverDefinition.selectors === undefined &&
blockType.selectors
) {
newDefinition = {
...serverDefinition,
selectors: blockType.selectors,
};
}

// The `blockHooks` prop is not yet included in the server provided
// definitions and needs to be polyfilled. This can be removed when the
// minimum supported WordPress is >= 6.4.
Expand Down

1 comment on commit 62198d2

@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 62198d2.
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/8733652489
📝 Reported issues:

Please sign in to comment.