]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
refactor(compiler-sfc): reuse `forAliasRE` regex from compiler-core (#9568)
authorTycho <jh.leong@outlook.com>
Fri, 10 Nov 2023 06:22:00 +0000 (14:22 +0800)
committerGitHub <noreply@github.com>
Fri, 10 Nov 2023 06:22:00 +0000 (14:22 +0800)
packages/compiler-core/src/transforms/vFor.ts
packages/compiler-core/src/utils.ts
packages/compiler-sfc/src/script/importUsageCheck.ts

index a44532c0d58b582712a14eb27a26b138c9211397..56144dcd284c6f299e4200e6e1a5bb4477fa3c6a 100644 (file)
@@ -37,7 +37,8 @@ import {
   isTemplateNode,
   isSlotOutlet,
   injectProp,
-  findDir
+  findDir,
+  forAliasRE
 } from '../utils'
 import {
   RENDER_LIST,
@@ -308,7 +309,6 @@ export function processFor(
   }
 }
 
-const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/
 // This regex doesn't cover the case if key or index aliases have destructuring,
 // but those do not make sense in the first place, so this works in practice.
 const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/
index bd2882b09e22a5bd39531c0b724511230acf410c..baffe5086f621f3dff376ebe14704bbc55e5f225 100644 (file)
@@ -519,3 +519,5 @@ export function getMemoedVNodeCall(node: BlockCodegenNode | MemoExpression) {
     return node
   }
 }
+
+export const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/
index a7e2e6f3565dd49f77618d54123c66563800dc97..34e95f1918b40decd1735a9a64710e94e6165f2a 100644 (file)
@@ -4,6 +4,7 @@ import {
   NodeTypes,
   SimpleExpressionNode,
   createRoot,
+  forAliasRE,
   parserOptions,
   transform,
   walkIdentifiers
@@ -87,8 +88,6 @@ function resolveTemplateUsageCheckString(sfc: SFCDescriptor) {
   return code
 }
 
-const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/
-
 function processExp(exp: string, dir?: string): string {
   if (/ as\s+\w|<.*>|:/.test(exp)) {
     if (dir === 'slot') {