From 3949aa1828bf56cc0d6b8e5a72ccb8e1435a69cc Mon Sep 17 00:00:00 2001 From: Jarda Snajdr Date: Mon, 28 Aug 2023 13:57:59 +0200 Subject: [PATCH] Remove the apiVersion and ancestor polyfills --- packages/blocks/src/api/test/registration.js | 74 -------------------- packages/blocks/src/store/reducer.js | 28 -------- 2 files changed, 102 deletions(-) diff --git a/packages/blocks/src/api/test/registration.js b/packages/blocks/src/api/test/registration.js index 98c4c4f4ee76b2..e5c89d2cd8fa39 100644 --- a/packages/blocks/src/api/test/registration.js +++ b/packages/blocks/src/api/test/registration.js @@ -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'; diff --git a/packages/blocks/src/store/reducer.js b/packages/blocks/src/store/reducer.js index 8853db0f9b4683..83d2fb05d768fd 100644 --- a/packages/blocks/src/store/reducer.js +++ b/packages/blocks/src/store/reducer.js @@ -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. @@ -102,7 +75,6 @@ function bootstrappedBlockTypes( state = {}, action ) { ) { newDefinition = { ...serverDefinition, - ...newDefinition, selectors: blockType.selectors, }; }