feat(compiler): expression prefixing + v-for scope analysis

This commit is contained in:
Evan You
2019-09-23 13:25:18 -04:00
parent b04be6a561
commit e57cb51066
8 changed files with 209 additions and 97 deletions

View File

@@ -348,17 +348,14 @@ function genFor(node: ForNode, context: CodegenContext) {
genExpression(source, context)
push(`, (`)
if (valueAlias) {
// not using genExpression here because these aliases can only be code
// that is valid in the function argument position, so the parse rule can
// be off and they don't need identifier prefixing anyway.
push(valueAlias.content, valueAlias)
genExpression(valueAlias, context)
}
if (keyAlias) {
if (!valueAlias) {
push(`_`)
}
push(`, `)
push(keyAlias.content, keyAlias)
genExpression(keyAlias, context)
}
if (objectIndexAlias) {
if (!keyAlias) {
@@ -369,7 +366,7 @@ function genFor(node: ForNode, context: CodegenContext) {
}
}
push(`, `)
push(objectIndexAlias.content, objectIndexAlias)
genExpression(objectIndexAlias, context)
}
push(`) => `)
genChildren(children, context)