Skip to content

Commit

Permalink
Remove the apiVersion and ancestor polyfills
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnajdr committed Aug 28, 2023
1 parent f22d37d commit 3949aa1
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 102 deletions.
74 changes: 0 additions & 74 deletions packages/blocks/src/api/test/registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,80 +388,6 @@ describe( 'blocks', () => {
} );
} );

// This test can be removed once the polyfill for apiVersion gets removed.
it( 'should apply apiVersion on the client when not set on the server', () => {
const blockName = 'core/test-block-back-compat';
unstable__bootstrapServerSideBlockDefinitions( {
[ blockName ]: {
category: 'widgets',
},
} );
unstable__bootstrapServerSideBlockDefinitions( {
[ blockName ]: {
apiVersion: 3,
category: 'ignored',
},
} );

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

// This test can be removed once the polyfill for ancestor gets removed.
it( 'should apply ancestor on the client when not set on the server', () => {
const blockName = 'core/test-block-with-ancestor';
unstable__bootstrapServerSideBlockDefinitions( {
[ blockName ]: {
category: 'widgets',
},
} );
unstable__bootstrapServerSideBlockDefinitions( {
[ blockName ]: {
ancestor: 'core/test-block-ancestor',
category: 'ignored',
},
} );

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

// 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';
Expand Down
28 changes: 0 additions & 28 deletions packages/blocks/src/store/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,33 +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 ) {
// We still need to polyfill `apiVersion` for WordPress version
// lower than 5.7. If it isn't present in the definition shared
// from the server, we try to fallback to the definition passed.
// @see https://github.com/WordPress/gutenberg/pull/29279
if (
serverDefinition.apiVersion === undefined &&
blockType.apiVersion
) {
newDefinition = {
...serverDefinition,
...newDefinition,
apiVersion: blockType.apiVersion,
};
}
// The `ancestor` prop is not included in the definitions shared
// from the server yet, so it needs to be polyfilled as well.
// @see https://github.com/WordPress/gutenberg/pull/39894
if (
serverDefinition.ancestor === undefined &&
blockType.ancestor
) {
newDefinition = {
...serverDefinition,
...newDefinition,
ancestor: blockType.ancestor,
};
}
// The `selectors` prop is not yet included in the server provided
// definitions. Polyfill it as well. This can be removed when the
// minimum supported WordPress is >= 6.3.
Expand All @@ -102,7 +75,6 @@ function bootstrappedBlockTypes( state = {}, action ) {
) {
newDefinition = {
...serverDefinition,
...newDefinition,
selectors: blockType.selectors,
};
}
Expand Down

0 comments on commit 3949aa1

Please sign in to comment.