3 import { parseFor } from 'compiler/parser/index'
4 import { getAndRemoveAttr, addRawAttr } from 'compiler/helpers'
7 * Map the following syntax to corresponding attrs:
9 * <recycle-list for="(item, i) in longList" switch="cellType">
10 * <cell-slot case="A"> ... </cell-slot>
11 * <cell-slot case="B"> ... </cell-slot>
15 export function preTransformRecycleList (
17 options: WeexCompilerOptions
19 const exp = getAndRemoveAttr(el, 'for')
22 options.warn(`Invalid <recycle-list> syntax: missing "for" expression.`)
27 const res = parseFor(exp)
30 options.warn(`Invalid <recycle-list> syntax: ${exp}.`)
35 addRawAttr(el, ':list-data', res.for)
36 addRawAttr(el, 'binding-expression', res.for)
37 addRawAttr(el, 'alias', res.alias)
39 // (item, key, index) for object iteration
40 // is this even supported?
41 addRawAttr(el, 'index', res.iterator2)
42 } else if (res.iterator1) {
43 addRawAttr(el, 'index', res.iterator1)
46 const switchKey = getAndRemoveAttr(el, 'switch')
48 addRawAttr(el, 'switch', switchKey)