From b7e51e7aeeaa78562bb5734df641c518fa8fc2d1 Mon Sep 17 00:00:00 2001 From: Glen Davies Date: Tue, 22 Jun 2021 09:01:58 +1200 Subject: [PATCH] Add optional chaining to prevent exception if activeFormats not defined (#32526) (#32527) Co-authored-by: Glen Davies --- packages/block-editor/src/components/rich-text/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-editor/src/components/rich-text/utils.js b/packages/block-editor/src/components/rich-text/utils.js index 16bcb2dd23a2c..f1385eda82e26 100644 --- a/packages/block-editor/src/components/rich-text/utils.js +++ b/packages/block-editor/src/components/rich-text/utils.js @@ -5,7 +5,7 @@ import { regexp } from '@wordpress/shortcode'; import deprecated from '@wordpress/deprecated'; export function addActiveFormats( value, activeFormats ) { - if ( activeFormats.length ) { + if ( activeFormats?.length ) { let index = value.formats.length; while ( index-- ) {