mirror of https://github.com/vuejs/core.git
refactor(compiler-sfc): reuse `forAliasRE` regex from compiler-core (#9568)
This commit is contained in:
parent
ae6f164b03
commit
d5fd343555
|
@ -37,7 +37,8 @@ import {
|
||||||
isTemplateNode,
|
isTemplateNode,
|
||||||
isSlotOutlet,
|
isSlotOutlet,
|
||||||
injectProp,
|
injectProp,
|
||||||
findDir
|
findDir,
|
||||||
|
forAliasRE
|
||||||
} from '../utils'
|
} from '../utils'
|
||||||
import {
|
import {
|
||||||
RENDER_LIST,
|
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,
|
// 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.
|
// but those do not make sense in the first place, so this works in practice.
|
||||||
const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/
|
const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/
|
||||||
|
|
|
@ -519,3 +519,5 @@ export function getMemoedVNodeCall(node: BlockCodegenNode | MemoExpression) {
|
||||||
return node
|
return node
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/
|
||||||
|
|
|
@ -4,6 +4,7 @@ import {
|
||||||
NodeTypes,
|
NodeTypes,
|
||||||
SimpleExpressionNode,
|
SimpleExpressionNode,
|
||||||
createRoot,
|
createRoot,
|
||||||
|
forAliasRE,
|
||||||
parserOptions,
|
parserOptions,
|
||||||
transform,
|
transform,
|
||||||
walkIdentifiers
|
walkIdentifiers
|
||||||
|
@ -87,8 +88,6 @@ function resolveTemplateUsageCheckString(sfc: SFCDescriptor) {
|
||||||
return code
|
return code
|
||||||
}
|
}
|
||||||
|
|
||||||
const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/
|
|
||||||
|
|
||||||
function processExp(exp: string, dir?: string): string {
|
function processExp(exp: string, dir?: string): string {
|
||||||
if (/ as\s+\w|<.*>|:/.test(exp)) {
|
if (/ as\s+\w|<.*>|:/.test(exp)) {
|
||||||
if (dir === 'slot') {
|
if (dir === 'slot') {
|
||||||
|
|
Loading…
Reference in New Issue