From 4d1d1c36de1276f179d653b073553e02878f530e Mon Sep 17 00:00:00 2001 From: ischanx Date: Sat, 4 Mar 2023 00:06:03 +0800 Subject: [PATCH] fix(squence): getBBox() returns zero --- packages/mermaid/src/utils.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/mermaid/src/utils.ts b/packages/mermaid/src/utils.ts index 69d0ac2ef..0c4b9d1a8 100644 --- a/packages/mermaid/src/utils.ts +++ b/packages/mermaid/src/utils.ts @@ -772,6 +772,9 @@ export const calculateTextDimensions: ( .style('font-family', fontFamily); const bBox = (textElem._groups || textElem)[0][0].getBBox(); + if (bBox.width === 0 && bBox.height === 0) { + throw new Error('svg element not in render tree'); + } dim.width = Math.round(Math.max(dim.width, bBox.width)); cheight = Math.round(bBox.height); dim.height += cheight;