@@ -4,47 +4,49 @@ const stripParensRE = /^\(|\)$/g;
4
4
const variableRE = / ^ \s * [ a - z A - Z \$ _ ] [ a - z A - Z \d _ ] * \s * $ / ;
5
5
6
6
exports = module . exports = function ( ) {
7
-
8
- this . register ( 'template-parse-ast-attr-v-for' , function parseDirectivesFor ( { item, name, expr, parentScope } ) {
7
+
8
+ this . register ( 'template-parse-ast-attr-v-for' , function parseDirectivesFor ( { item, name, expr, scope } ) {
9
9
let res = { } ;
10
- let scope = { } ;
10
+ let currentScope = { } ;
11
11
let inMatch = expr . match ( forAliasRE ) ;
12
12
let variableMatch = expr . match ( variableRE ) ;
13
13
if ( variableMatch ) {
14
14
// e.g: v-for="items"
15
15
res . alias = 'item' ;
16
16
res . for = variableMatch [ 0 ] . trim ( ) ;
17
- scope . for = res . for ;
18
- scope . declared = [ ] ;
17
+ currentScope . for = res . for ;
18
+ currentScope . declared = [ ] ;
19
19
}
20
20
21
21
if ( inMatch ) {
22
- scope . declared = scope . declared || [ ] ;
22
+ currentScope . declared = currentScope . declared || [ ] ;
23
23
res . for = inMatch [ 2 ] . trim ( ) ;
24
+ currentScope . for = res . for ;
24
25
let alias = inMatch [ 1 ] . trim ( ) . replace ( stripParensRE , '' ) ;
25
26
let iteratorMatch = alias . match ( forIteratorRE ) ;
26
27
if ( iteratorMatch ) {
27
28
res . alias = alias . replace ( forIteratorRE , '' ) . trim ( ) ;
28
- scope . declared . push ( res . alias ) ;
29
- scope . alias = res . alias ;
29
+ currentScope . declared . push ( res . alias ) ;
30
+ currentScope . alias = res . alias ;
30
31
res . iterator1 = iteratorMatch [ 1 ] . trim ( ) ;
31
- scope . iterator1 = res . iterator1 ;
32
- scope . declared . push ( res . iterator1 ) ;
32
+ currentScope . iterator1 = res . iterator1 ;
33
+ currentScope . declared . push ( res . iterator1 ) ;
33
34
if ( iteratorMatch [ 2 ] ) {
34
35
res . iterator2 = iteratorMatch [ 2 ] . trim ( ) ;
35
- scope . iterator2 = res . iterator2 ;
36
- scope . declared . push ( res . iterator2 ) ;
36
+ currentScope . iterator2 = res . iterator2 ;
37
+ currentScope . declared . push ( res . iterator2 ) ;
37
38
}
38
39
} else {
39
40
res . alias = alias ;
40
- scope . alias = alias ;
41
- scope . declared . push ( alias ) ;
41
+ currentScope . alias = alias ;
42
+ currentScope . declared . push ( alias ) ;
42
43
}
43
44
}
44
- if ( parentScope )
45
- scope . parent = parentScope ;
45
+ if ( scope ) {
46
+ currentScope . parent = scope ;
47
+ }
46
48
return {
47
- scope : scope ,
49
+ scope : currentScope ,
48
50
attrs : {
49
51
'wx:for' : `{{ ${ res . for } }}` ,
50
52
'wx:for-index' : `${ res . iterator1 || 'index' } ` ,
0 commit comments