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

Commit 499ecb6

Browse files
roykhowavvves
authored andcommitted
Don't register or unregister if block can't be found (#11872)
1 parent d92e8c7 commit 499ecb6

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

assets/js/atomic/utils/blocks-registration-manager/blocks-registration-manager.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* External dependencies
3+
*/
4+
import { getBlockType } from '@wordpress/blocks';
5+
16
/**
27
* Internal dependencies
38
*/
@@ -108,6 +113,11 @@ export class BlockRegistrationManager
108113
) {
109114
continue;
110115
}
116+
117+
if ( ! getBlockType( blockWithRestrictionName ) ) {
118+
continue;
119+
}
120+
111121
this.blockRegistrationStrategy = BLOCKS_WITH_RESTRICTION[
112122
blockWithRestrictionName
113123
].isVariationBlock
@@ -130,6 +140,10 @@ export class BlockRegistrationManager
130140
*/
131141
registerBlocksAfterLeavingRestrictedArea() {
132142
for ( const unregisteredBlockName of this.unregisteredBlocks ) {
143+
if ( ! getBlockType( unregisteredBlockName ) ) {
144+
continue;
145+
}
146+
133147
const restrictedBlockData =
134148
BLOCKS_WITH_RESTRICTION[ unregisteredBlockName ];
135149
this.blockRegistrationStrategy = BLOCKS_WITH_RESTRICTION[

0 commit comments

Comments
 (0)