From 9ccda3e96ffcae09b360cb5005e74cf10b20ea73 Mon Sep 17 00:00:00 2001 From: vector Date: Thu, 16 Feb 2023 19:04:46 +0800 Subject: [PATCH] fix: donot empty text when only has title elem (#3248) --- packages/x6-common/src/dom/text.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/x6-common/src/dom/text.ts b/packages/x6-common/src/dom/text.ts index 98d7929d52e..4e1c9492fcc 100644 --- a/packages/x6-common/src/dom/text.ts +++ b/packages/x6-common/src/dom/text.ts @@ -198,7 +198,14 @@ export function text( const autoLineHeight = defaultLineHeight === 'auto' const lineHeight = autoLineHeight ? '1.5em' : defaultLineHeight || '1em' - empty(elem) + let needEmptyElem = true + const childs = elem.children + if (childs.length === 1 && childs[0].tagName.toUpperCase() === 'TITLE') { + needEmptyElem = false + } + if (needEmptyElem) { + empty(elem) + } attr(elem, { // Preserve spaces, do not consecutive spaces to get collapsed to one.