Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Don't register or unregister if block can't be found (#11872)
Browse files Browse the repository at this point in the history
  • Loading branch information
roykho authored Nov 22, 2023
1 parent ae714c7 commit 8376e1d
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* External dependencies
*/
import { getBlockType } from '@wordpress/blocks';

/**
* Internal dependencies
*/
Expand Down Expand Up @@ -108,6 +113,11 @@ export class BlockRegistrationManager
) {
continue;
}

if ( ! getBlockType( blockWithRestrictionName ) ) {
continue;
}

this.blockRegistrationStrategy = BLOCKS_WITH_RESTRICTION[
blockWithRestrictionName
].isVariationBlock
Expand All @@ -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[
Expand Down

0 comments on commit 8376e1d

Please sign in to comment.