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

Don't register or unregister if block can't be found #11872

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading