From 31e00e7c1943bf22f27459dd0ebe691f28e6ea62 Mon Sep 17 00:00:00 2001 From: betavs <34408516+betavs@users.noreply.github.com> Date: Sun, 22 Sep 2024 21:32:11 +0800 Subject: [PATCH] fix(components): [descriptions-cell] redundant slot function calls (#18330) --- .../descriptions/src/descriptions-cell.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/components/descriptions/src/descriptions-cell.ts b/packages/components/descriptions/src/descriptions-cell.ts index 69301b8213..b5880df4a0 100644 --- a/packages/components/descriptions/src/descriptions-cell.ts +++ b/packages/components/descriptions/src/descriptions-cell.ts @@ -44,8 +44,8 @@ export default defineComponent({ const { border, direction } = this.descriptions const isVertical = direction === 'vertical' - const label = this.cell?.children?.label?.() || item.label - const content = this.cell?.children?.default?.() + const renderLabel = () => this.cell?.children?.label?.() || item.label + const renderContent = () => this.cell?.children?.default?.() const span = item.span const rowspan = item.rowspan const align = item.align ? `is-${item.align}` : '' @@ -76,7 +76,7 @@ export default defineComponent({ colSpan: isVertical ? span : 1, rowspan: isVertical ? 1 : rowspan, }, - label + renderLabel() ), directives ) @@ -97,11 +97,13 @@ export default defineComponent({ colSpan: isVertical ? span : span * 2 - 1, rowspan: isVertical ? rowspan * 2 - 1 : rowspan, }, - content + renderContent() ), directives ) - default: + default: { + const label = renderLabel() + return withDirectives( h( 'td', @@ -126,12 +128,13 @@ export default defineComponent({ { class: [ns.e('content'), className], }, - content + renderContent() ), ] ), directives ) + } } }, })