@@ -14,18 +14,17 @@ const EachBinded = {
14
14
meta : {
15
15
serializeNodes : true
16
16
} ,
17
- serializeNodes : function ( node ) {
17
+ serializeNodes ( node ) {
18
18
return mask_stringify ( node ) ;
19
19
} ,
20
20
//modelRef: null,
21
- render : function ( model , ctx , container , ctr , children ) {
21
+ render ( model , ctx , container , ctr , children ) {
22
22
//this.modelRef = this.expression;
23
- var array = expression_eval ( this . expression , model , ctx , ctr ) ;
24
- if ( array == null )
23
+ let array = expression_eval ( this . expression , model , ctx , ctr ) ;
24
+ if ( array == null ) {
25
25
return ;
26
-
26
+ }
27
27
arr_createRefs ( array ) ;
28
-
29
28
build (
30
29
this . nodes ,
31
30
array ,
@@ -36,8 +35,8 @@ const EachBinded = {
36
35
) ;
37
36
} ,
38
37
39
- renderEnd : function ( els , model , ctx , container , ctr ) {
40
- var compo = new EachStatement ( this , this . attr ) ;
38
+ renderEnd ( els , model , ctx , container , ctr ) {
39
+ let compo = new EachStatement ( this , this . attr ) ;
41
40
42
41
_renderPlaceholder ( this , compo , container ) ;
43
42
_compo_initAndBind ( compo , this , model , ctx , container , ctr ) ;
@@ -46,34 +45,34 @@ const EachBinded = {
46
45
47
46
} ;
48
47
49
- var EachItem = class_create ( {
48
+ const EachItem = class_create ( {
50
49
compoName : 'each::item' ,
51
50
scope : null ,
52
51
model : null ,
53
52
modelRef : null ,
54
53
parent : null ,
55
54
//#if (NODE)
56
- renderStart : function ( ) {
57
- var expr = this . parent . expression ;
55
+ renderStart ( ) {
56
+ let expr = this . parent . expression ;
58
57
this . modelRef = ''
59
58
+ ( expr === '.' ? '' : ( '(' + expr + ')' ) )
60
59
+ '."'
61
60
+ this . scope . index
62
61
+ '"' ;
63
62
} ,
64
63
//#endif
65
- renderEnd : function ( els ) {
64
+ renderEnd ( els ) {
66
65
this . elements = els ;
67
66
} ,
68
- dispose : function ( ) {
67
+ dispose ( ) {
69
68
if ( this . elements != null ) {
70
69
this . elements . length = 0 ;
71
70
this . elements = null ;
72
71
}
73
72
}
74
73
} ) ;
75
74
76
- var EachStatement = class_create ( ALoopBindedStatement , {
75
+ const EachStatement = class_create ( ALoopBindedStatement , {
77
76
compoName : '+each' ,
78
77
constructor : function EachStatement ( node , attr ) {
79
78
this . expression = node . expression ;
@@ -85,13 +84,13 @@ var EachStatement = class_create(ALoopBindedStatement, {
85
84
this . node = node ;
86
85
this . components = node . components ;
87
86
} ,
88
- _getModel : function ( compo ) {
87
+ _getModel ( compo ) {
89
88
return compo . model ;
90
89
} ,
91
- _build : function ( node , model , ctx , component ) {
92
- var fragment = _document . createDocumentFragment ( ) ;
90
+ build ( model ) {
91
+ let fragment = _document . createDocumentFragment ( ) ;
93
92
94
- build ( node . nodes , model , ctx , fragment , component ) ;
93
+ build ( this . node . nodes , model , { } , fragment , this ) ;
95
94
96
95
return fragment ;
97
96
}
@@ -100,18 +99,15 @@ var EachStatement = class_create(ALoopBindedStatement, {
100
99
// METHODS
101
100
102
101
function build ( nodes , array , ctx , container , ctr , elements ?) {
103
- var imax = array . length ,
104
- nodes_ = new Array ( imax ) ,
105
- i = 0 , node ;
106
-
107
- for ( ; i < imax ; i ++ ) {
108
- node = createEachNode ( nodes , i ) ;
102
+ let imax = array . length ;
103
+ for ( let i = 0 ; i < imax ; i ++ ) {
104
+ let node = createEachNode ( nodes , i ) ;
109
105
builder_build ( node , array [ i ] , ctx , container , ctr , elements ) ;
110
106
}
111
107
}
112
108
113
109
function createEachNode ( nodes , index ) {
114
- var item = new EachItem ;
110
+ let item = new EachItem ;
115
111
item . scope = { index : index } ;
116
112
117
113
return {
0 commit comments