From f275c2abfdd4b86e042ec4142ef45879be4f971d Mon Sep 17 00:00:00 2001 From: KazariEX <1364035137@qq.com> Date: Sat, 2 Nov 2024 17:50:26 +0800 Subject: [PATCH] fix(language-core): generate empty scoped classname for `:class` --- .../language-core/lib/codegen/template/element.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/language-core/lib/codegen/template/element.ts b/packages/language-core/lib/codegen/template/element.ts index 583c7b5c8b..2c68310921 100644 --- a/packages/language-core/lib/codegen/template/element.ts +++ b/packages/language-core/lib/codegen/template/element.ts @@ -685,11 +685,16 @@ function* generateReferencesForScopedCssClasses( }); for (const literal of literals) { - const classes = collectClasses( - literal.text, - literal.end - literal.text.length - 1 + startOffset - ); - ctx.scopedClasses.push(...classes); + if (literal.text) { + const classes = collectClasses( + literal.text, + literal.end - literal.text.length - 1 + startOffset + ); + ctx.scopedClasses.push(...classes); + } + else { + ctx.emptyClassOffsets.push(literal.end - 1 + startOffset); + } } function walkArrayLiteral(node: ts.ArrayLiteralExpression) {