File tree 2 files changed +37
-0
lines changed
src/platforms/weex/compiler/modules/recycle-list
2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 3
3
import { transformText } from './text'
4
4
import { transformVBind } from './v-bind'
5
5
import { transformVIf } from './v-if'
6
+ import { transformVFor } from './v-for'
6
7
7
8
let currentRecycleList = null
8
9
@@ -16,6 +17,7 @@ function transformNode (el: ASTElement) {
16
17
if ( currentRecycleList ) {
17
18
// TODO
18
19
transformVIf ( el )
20
+ transformVFor ( el )
19
21
transformVBind ( el )
20
22
}
21
23
}
Original file line number Diff line number Diff line change
1
+ /* @flow */
2
+
3
+ import { addAttr } from 'compiler/helpers'
4
+
5
+ function isVForAttr ( name : string ) : boolean {
6
+ return / ^ v \- f o r / . test ( name )
7
+ }
8
+
9
+ export function transformVFor ( el : ASTElement ) {
10
+ for ( const attr in el . attrsMap ) {
11
+ if ( ! isVForAttr ( attr ) ) {
12
+ continue
13
+ }
14
+ const desc : Object = {
15
+ '@expression' : el . for ,
16
+ '@alias' : el . alias
17
+ }
18
+ if ( el . iterator1 ) {
19
+ desc [ '@index' ] = el . iterator1
20
+ }
21
+ if ( el . iterator2 ) {
22
+ desc [ '@key' ] = el . iterator1
23
+ desc [ '@index' ] = el . iterator2
24
+ }
25
+ addAttr ( el , '[[repeat]]' , desc )
26
+ el . attrsMap [ '[[repeat]]' ] = desc
27
+ el . attrsList . push ( { name : '[[repeat]]' , value : desc } )
28
+ delete el . attrsMap [ attr ]
29
+ delete el . for
30
+ delete el . alias
31
+ delete el . key
32
+ delete el . iterator1
33
+ delete el . iterator2
34
+ }
35
+ }
You can’t perform that action at this time.
0 commit comments