From: 白雾三语 <32354856+baiwusanyu-c@users.noreply.github.com> Date: Thu, 18 May 2023 05:07:08 +0000 (+0800) Subject: fix(compiler-sfc): parses correctly when inline mode is off (#8337) X-Git-Tag: v3.3.3~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ecbd42a1444e3c599e464dec002e43d548d99669;p=thirdparty%2Fvuejs%2Fcore.git fix(compiler-sfc): parses correctly when inline mode is off (#8337) close #6088 --- diff --git a/packages/compiler-sfc/__tests__/compileScript.spec.ts b/packages/compiler-sfc/__tests__/compileScript.spec.ts index afe656b4a2..6da274dd8a 100644 --- a/packages/compiler-sfc/__tests__/compileScript.spec.ts +++ b/packages/compiler-sfc/__tests__/compileScript.spec.ts @@ -804,6 +804,25 @@ describe('SFC compile + + `, + { + inlineTemplate: false + } + ) + ).not.toThrowError() + }) }) describe('with TypeScript', () => { diff --git a/packages/compiler-sfc/src/script/importUsageCheck.ts b/packages/compiler-sfc/src/script/importUsageCheck.ts index 59473a9dda..b42397d573 100644 --- a/packages/compiler-sfc/src/script/importUsageCheck.ts +++ b/packages/compiler-sfc/src/script/importUsageCheck.ts @@ -83,7 +83,9 @@ function processExp(exp: string, dir?: string): string { } else if (dir === 'for') { const inMatch = exp.match(forAliasRE) if (inMatch) { - const [, LHS, RHS] = inMatch + let [, LHS, RHS] = inMatch + // #6088 + LHS = LHS.trim().replace(/^\(|\)$/g, '') return processExp(`(${LHS})=>{}`) + processExp(RHS) } }