From 97d9087b8c40cab06e7f4c1faa82370437148a25 Mon Sep 17 00:00:00 2001 From: Jasper Huang Date: Wed, 8 Nov 2023 14:07:52 -0800 Subject: [PATCH] provide reasonable defaults --- src/components/HTMLEngineProvider/htmlEngineUtils.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/HTMLEngineProvider/htmlEngineUtils.js b/src/components/HTMLEngineProvider/htmlEngineUtils.js index 3c93873845b1..4495cb8ff136 100644 --- a/src/components/HTMLEngineProvider/htmlEngineUtils.js +++ b/src/components/HTMLEngineProvider/htmlEngineUtils.js @@ -1,3 +1,5 @@ +import lodashGet from 'lodash/get'; + const MAX_IMG_DIMENSIONS = 512; /** @@ -52,7 +54,7 @@ function isChildOfNode(tnode, predicate) { * @returns {Boolean} */ function isChildOfComment(tnode) { - return isChildOfNode(tnode, (node) => isCommentTag(node.domNode.name)); + return isChildOfNode(tnode, (node) => isCommentTag(lodashGet(node, 'domNode.name', ''))); } /** @@ -62,7 +64,7 @@ function isChildOfComment(tnode) { * @returns {Boolean} */ function isChildOfH1(tnode) { - return isChildOfNode(tnode, (node) => node.domNode.name.toLowerCase() === 'h1'); + return isChildOfNode(tnode, (node) => lodashGet(node, 'domNode.name', '').toLowerCase() === 'h1'); } export {computeEmbeddedMaxWidth, isChildOfComment, isCommentTag, isChildOfH1};