From 8376e1d4615f4650c148e8e866234619d38005c0 Mon Sep 17 00:00:00 2001 From: Roy Ho Date: Wed, 22 Nov 2023 04:50:56 -0800 Subject: [PATCH] Don't register or unregister if block can't be found (#11872) --- .../blocks-registration-manager.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/assets/js/atomic/utils/blocks-registration-manager/blocks-registration-manager.ts b/assets/js/atomic/utils/blocks-registration-manager/blocks-registration-manager.ts index 79446bd91e3..7ca69ae89e4 100644 --- a/assets/js/atomic/utils/blocks-registration-manager/blocks-registration-manager.ts +++ b/assets/js/atomic/utils/blocks-registration-manager/blocks-registration-manager.ts @@ -1,3 +1,8 @@ +/** + * External dependencies + */ +import { getBlockType } from '@wordpress/blocks'; + /** * Internal dependencies */ @@ -108,6 +113,11 @@ export class BlockRegistrationManager ) { continue; } + + if ( ! getBlockType( blockWithRestrictionName ) ) { + continue; + } + this.blockRegistrationStrategy = BLOCKS_WITH_RESTRICTION[ blockWithRestrictionName ].isVariationBlock @@ -130,6 +140,10 @@ export class BlockRegistrationManager */ registerBlocksAfterLeavingRestrictedArea() { for ( const unregisteredBlockName of this.unregisteredBlocks ) { + if ( ! getBlockType( unregisteredBlockName ) ) { + continue; + } + const restrictedBlockData = BLOCKS_WITH_RESTRICTION[ unregisteredBlockName ]; this.blockRegistrationStrategy = BLOCKS_WITH_RESTRICTION[