File tree 2 files changed +24
-15
lines changed
src/platforms/weex/compiler/modules/recycle-list
2 files changed +24
-15
lines changed Original file line number Diff line number Diff line change 1
1
/* @flow */
2
2
3
- import { addAttr } from 'compiler/helpers '
3
+ import { transformText } from './text '
4
4
5
5
let currentRecycleList = null
6
6
@@ -20,27 +20,14 @@ function postTransformNode (el: ASTElement) {
20
20
if ( currentRecycleList ) {
21
21
// <text>: transform children text into value attr
22
22
if ( el . tag === 'text' ) {
23
- addAttr ( el , 'value' , genText ( el . children [ 0 ] ) )
24
- el . children = [ ]
25
- el . plain = false
23
+ transformText ( el )
26
24
}
27
25
}
28
26
if ( el === currentRecycleList ) {
29
27
currentRecycleList = null
30
28
}
31
29
}
32
30
33
- function genText ( node ) {
34
- const value = node . type === 3
35
- ? node . text
36
- : node . type === 2
37
- ? node . tokens . length === 1
38
- ? node . tokens [ 0 ]
39
- : node . tokens
40
- : ''
41
- return JSON . stringify ( value )
42
- }
43
-
44
31
export default {
45
32
preTransformNode,
46
33
transformNode,
Original file line number Diff line number Diff line change
1
+ /* @flow */
2
+
3
+ import { addAttr } from 'compiler/helpers'
4
+
5
+ function genText ( node : ASTNode ) {
6
+ const value = node . type === 3
7
+ ? node . text
8
+ : node . type === 2
9
+ ? node . tokens . length === 1
10
+ ? node . tokens [ 0 ]
11
+ : node . tokens
12
+ : ''
13
+ return JSON . stringify ( value )
14
+ }
15
+
16
+ export function transformText ( el : ASTElement ) {
17
+ // weex <text> can only contain text, so the parser
18
+ // always generates a single child.
19
+ addAttr ( el , 'value' , genText ( el . children [ 0 ] ) )
20
+ el . children = [ ]
21
+ el . plain = false
22
+ }
You can’t perform that action at this time.
0 commit comments