From ab0df3c818f730d744aaac6fdab0c36d76d44927 Mon Sep 17 00:00:00 2001 From: Jeremy Herve Date: Fri, 18 Oct 2024 20:18:20 +0200 Subject: [PATCH] Story Block: be more defensive to avoid error in block previews (#39807) Fixes #39694 --- projects/plugins/jetpack/changelog/fix-story-block-fatal | 4 ++++ .../jetpack/extensions/blocks/story/player/modal/index.js | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 projects/plugins/jetpack/changelog/fix-story-block-fatal diff --git a/projects/plugins/jetpack/changelog/fix-story-block-fatal b/projects/plugins/jetpack/changelog/fix-story-block-fatal new file mode 100644 index 0000000000000..bb6d0c7d2abd9 --- /dev/null +++ b/projects/plugins/jetpack/changelog/fix-story-block-fatal @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +Story Block: avoid error when previewing block styles in development version of the Gutenberg plugin. diff --git a/projects/plugins/jetpack/extensions/blocks/story/player/modal/index.js b/projects/plugins/jetpack/extensions/blocks/story/player/modal/index.js index f9483a6a9f036..3e3f86b309446 100644 --- a/projects/plugins/jetpack/extensions/blocks/story/player/modal/index.js +++ b/projects/plugins/jetpack/extensions/blocks/story/player/modal/index.js @@ -69,7 +69,10 @@ class Modal extends Component { * Removes the specific mounting point for this modal from the DOM. */ cleanDOM() { - parentElement.removeChild( this.node ); + if ( this.node && parentElement && parentElement.contains( this.node ) ) { + parentElement.removeChild( this.node ); + } + this.node = null; } /**