efront 4.22.16 → 4.22.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,7 +23,8 @@ var isValidK = function (k) {
23
23
  var extractK = function (k) {
24
24
  return k.length < 16 && isFinite(k);
25
25
  };
26
- var noDulp = false, plength = 0;
26
+ var noDulp = false, plength = 0, dulp = false;
27
+ var hasOwnProperty = {}.hasOwnProperty;
27
28
  function _tostring(memery, preload, dist) {
28
29
  if (memery === undefined) return '';
29
30
  if (check(memery)) return String(memery);
@@ -40,7 +41,8 @@ function _tostring(memery, preload, dist) {
40
41
  }
41
42
  if (memery instanceof Date) return date(memery);
42
43
  if (memery instanceof RegExp) return regexp(memery);
43
- var d = preload.indexOf(memery.constructor);
44
+ var constructor = memery.constructor;
45
+ var d = preload.indexOf(constructor);
44
46
  var pre = memery instanceof Array ? "[" : "{";
45
47
  var aft = pre === "{" ? "}" : "]"
46
48
  if (d >= 0) pre = d + pre;
@@ -49,19 +51,34 @@ function _tostring(memery, preload, dist) {
49
51
  dist.push(undefined);
50
52
  for (var k in memery) {
51
53
  var v = memery[k];
54
+ if (!hasOwnProperty.call(memery, k)) {
55
+ if (!d || !hasOwnProperty.call(constructor.prototype, k)) break;
56
+ }
52
57
  if (v && typeof v === 'object' || typeof v === 'function') {
53
- var i = preload.indexOf(v);
54
- if (i >= 0) {
55
- if (noDulp) throw new Error(i18n`数据异常`);
56
- v = i;
58
+ if (v instanceof Date) {
59
+ v = date(v);
60
+ }
61
+ else if (v instanceof RegExp) {
62
+ v = regexp(v);
57
63
  }
58
64
  else {
59
- i = plength;
60
- preload.push(v);
61
- plength++;
62
- _tostring(v, preload, dist);
63
- if (noDulp) preload.pop();
64
- v = i;
65
+ var i = preload.indexOf(v);
66
+ if (i >= 0) {
67
+ if (noDulp) throw new Error(i18n`数据异常`);
68
+ v = i;
69
+ dulp = true;
70
+ }
71
+ else {
72
+ i = plength + dist.length;
73
+ preload.push(v);
74
+ v = _tostring(v, preload, dist);
75
+ if (!v.length) {
76
+ preload.pop();
77
+ continue;
78
+ }
79
+ if (noDulp) preload.pop();
80
+ v = i;
81
+ }
65
82
  }
66
83
  }
67
84
  else {
@@ -78,6 +95,7 @@ function _tostring(memery, preload, dist) {
78
95
  }
79
96
  inc++;
80
97
  }
98
+ if (arr.length && !arr[arr.length - 1].length) arr.push('');
81
99
  dist[index] = pre + arr.join(',') + aft;
82
100
  return dist[index];
83
101
  }
@@ -93,8 +111,10 @@ function stringify(memery, preload, hasDulp = true) {
93
111
  }
94
112
  else preload = [memery];
95
113
  var dist = [];
96
- plength = preload.length;
114
+ plength = preload.length - 1;
115
+ dulp = false;
97
116
  dist[0] = _tostring(memery, preload, dist);
117
+ if (dist.length === 1 && dulp) { dist.push(''); }
98
118
  return dist.join(',');
99
119
  }
100
120
  function parseValue(v) {
@@ -174,7 +194,7 @@ function scanblock(string, index, preload, obj) {
174
194
  case ",":
175
195
  d = spaces.trim(string.slice(start, match.index));
176
196
  if (preload === obj) isjsam = true;
177
- if (!d && typeof k === 'number') {
197
+ if (!d && typeof k === 'number' && !(obj instanceof Array)) {
178
198
  start = index;
179
199
  k = inc++;
180
200
  continue;
@@ -1,7 +1,7 @@
1
1
  var test = function (o) {
2
2
  var s = JSAM.stringify(o);
3
3
  var a = JSAM.parse(s);
4
- console.log(s, a);
4
+ if (!assert(a, o)) console.log(o, s.replace(/[\]\}],/g, '$&\r\n').split("\r\n").map((a, i) => `<${i}> ${a}`), a);
5
5
 
6
6
  };
7
7
  var test_self = function () {
@@ -51,9 +51,257 @@ var test_self = function () {
51
51
  test([{ "name": "用户", "open": true }, { "name": "导航", "open": true }, { "name": "商品", "open": true },]);
52
52
  console.log(JSAM.parse(`[1:2,3:2,4:5,6:7,8:2,9:2,10:2,11:2,12:13,14:13,15:16],"is_errored",null,"error_message","is_loading",false,"is_loaded",true,"is_readonly","loading","loading_promise","data","appid",,"sign","smap",{17:7,18:7},"zh","en"`))
53
53
  };
54
+
55
+
56
+ function test_deep() {
57
+ var addScope = function (groups) {
58
+ var parentScopes = [{ groups }];
59
+ groups.forEach((group, i) => {
60
+ var $scope = { $item: group, $index: i };
61
+ var ps = parentScopes.push($scope);
62
+ group.forEach((item, i) => {
63
+ var s = { $item: item, $index: i };
64
+ item.target = {
65
+ $scope: s,
66
+ parentScopes: ps,
67
+ $mounted: true,
68
+ $renderid: 1,
69
+ className: '',
70
+ $renders: [{ call() { } }],
71
+ a: function () {
72
+ var a = function () { };
73
+ a.className = 'a';
74
+ a.call = function () { };
75
+ return a;
76
+ },
77
+ $struct: {
78
+ emits: {},
79
+ waits: {},
80
+ binds: {},
81
+ attrs: [],
82
+ copys: [],
83
+ },
84
+ };
85
+ })
86
+
87
+ })
88
+ }
89
+ var files = [
90
+ [
91
+ { name: "a", size: 1, lastModified: 1721945589673, lastModifiedDate: new Date, path: '' },
92
+ { name: "b", size: 2, lastModified: 1721945589673, lastModifiedDate: new Date, path: '' },
93
+ ],
94
+ [
95
+ { name: "c", size: 2, lastModified: 1721945589673, lastModifiedDate: new Date, path: '' },
96
+ ],
97
+ [
98
+ { name: "d", size: 2, lastModified: 1721945589673, lastModifiedDate: new Date, path: '' },
99
+ ],
100
+ [
101
+ { name: "g", size: 2, lastModified: 1721945589673, lastModifiedDate: new Date, path: '' },
102
+ ],
103
+ [
104
+ { name: "e", size: 2, lastModified: 1721945589673, lastModifiedDate: new Date, path: '' },
105
+ { name: "f", size: 2, lastModified: 1721945589673, lastModifiedDate: new Date, path: '' },
106
+ ],
107
+ [
108
+ { name: "e", size: 2, lastModified: 1721945589673, lastModifiedDate: new Date, path: '' },
109
+ { name: "f", size: 2, lastModified: 1721945589673, lastModifiedDate: new Date, path: '' },
110
+ ],
111
+ [
112
+ { name: "a", size: 2, lastModified: 1721945589673, lastModifiedDate: new Date, path: '' },
113
+ { name: "b", size: 2, lastModified: 1721945589673, lastModifiedDate: new Date, path: '' },
114
+ ],
115
+ ];
116
+ addScope(files);
117
+ test(files);
118
+ }
119
+
120
+
121
+
122
+
123
+ function test_parse() {
124
+ var data = JSAM.parse(`[1,40,57,74,91,122,153],
125
+ [2,26],
126
+ {target:3,src:"blob:http://localhost/07d435d9-0a5e-4e30-9b73-b8c58cb4b4c7",name:"花粥.jpeg",lastModified:+1721945589673,"lastModifiedDate":2024-07-25T22:13:09.673Z,"webkitRelativePath":""},
127
+ {origin:2,$h_mounted00:null,$scope:4,$parentScopes:5,$struct:15,$renders:25,$mounted:true,$renderid:+2,complete:true,width:+120,height:+120},
128
+ {$key:+0,$item:2,$index:+0,m:2},
129
+ [6,14],
130
+ {groups:0,ylist:7,actived:+0,padding:8,close:9,xlist:10,url:11,xbox:12,loading:false,tags:13},
131
+ {className:"lattice- lattice lattice"},
132
+ {className:"padding- padding padding"},
133
+ {className:"chooseclose- chooseclose chooseclose"},
134
+ {className:"list- list list"},
135
+ [],
136
+ {className:"vbox- vbox vbox"},
137
+ [],
138
+ {$key:+0,$item:1,$index:+0,i:+0,g:1,$origin:1},
139
+ {emits:16,waits:17,if:,repeat:,copys:18,binds:21,attrs:22,props:23,ids:24,once:},
140
+ {},
141
+ {},
142
+ [19,20],
143
+ {namespaceURI:null,prefix:null,localName:"height",name:"height",value:"120",ownerElement:3,specified:true},
144
+ {namespaceURI:null,prefix:null,localName:"width",name:"width",value:"120",ownerElement:3,specified:true},
145
+ {},
146
+ {},
147
+ {height:+120,width:+120},
148
+ [],
149
+ [],
150
+ {target:27,src:"blob:http://localhost/b64ea880-2af7-4781-9318-ab967df43932",name:"陈一发儿.jpg",lastModified:+1721945107240,"lastModifiedDate":2024-07-25T22:05:07.240Z,"webkitRelativePath":""},
151
+ {origin:26,$h_mounted00:null,$scope:28,$parentScopes:5,$struct:29,$renders:39,$mounted:true,$renderid:+2,complete:true,width:+120,height:+120},
152
+ {$key:+1,$item:26,$index:+1,m:26},
153
+ {emits:30,waits:31,if:,repeat:,copys:32,binds:35,attrs:36,props:37,ids:38,once:},
154
+ {},
155
+ {},
156
+ [33,34],
157
+ {namespaceURI:null,prefix:null,localName:"height",name:"height",value:"120",ownerElement:27,specified:true},
158
+ {namespaceURI:null,prefix:null,localName:"width",name:"width",value:"120",ownerElement:27,specified:true},
159
+ {},
160
+ {},
161
+ {height:+120,width:+120},
162
+ [],
163
+ [],
164
+ [41],
165
+ {target:42,src:null,name:"ucbr.png",lastModified:+1670542984813,"lastModifiedDate":2022-12-08T23:43:04.813Z,"webkitRelativePath":""},
166
+ {origin:41,$h_mounted00:null,$scope:43,$parentScopes:44,$struct:46,$renders:56,$mounted:true,$renderid:+2,complete:true,width:+120,height:+120},
167
+ {$key:+0,$item:41,$index:+0,m:41},
168
+ [6,45],
169
+ {$key:+1,$item:40,$index:+1,i:+1,g:40,$origin:40},
170
+ {emits:47,waits:48,if:,repeat:,copys:49,binds:52,attrs:53,props:54,ids:55,once:},
171
+ {},
172
+ {},
173
+ [50,51],
174
+ {namespaceURI:null,prefix:null,localName:"height",name:"height",value:"120",ownerElement:42,specified:true},
175
+ {namespaceURI:null,prefix:null,localName:"width",name:"width",value:"120",ownerElement:42,specified:true},
176
+ {},
177
+ {},
178
+ {height:+120,width:+120},
179
+ [],
180
+ [],
181
+ [58],
182
+ {target:59,src:null,name:"kuwo.png",lastModified:+1672029521697,"lastModifiedDate":2022-12-26T04:38:41.697Z,"webkitRelativePath":""},
183
+ {origin:58,$h_mounted00:null,$scope:60,$parentScopes:61,$struct:63,$renders:73,$mounted:true,$renderid:+2,complete:true,width:+120,height:+120},
184
+ {$key:+0,$item:58,$index:+0,m:58},
185
+ [6,62],
186
+ {$key:+2,$item:57,$index:+2,i:+2,g:57,$origin:57},
187
+ {emits:64,waits:65,if:,repeat:,copys:66,binds:69,attrs:70,props:71,ids:72,once:},
188
+ {},
189
+ {},
190
+ [67,68],
191
+ {namespaceURI:null,prefix:null,localName:"height",name:"height",value:"120",ownerElement:59,specified:true},
192
+ {namespaceURI:null,prefix:null,localName:"width",name:"width",value:"120",ownerElement:59,specified:true},
193
+ {},
194
+ {},
195
+ {height:+120,width:+120},
196
+ [],
197
+ [],
198
+ [75],
199
+ {target:76,name:"icon.png",lastModified:+1586739267873,"lastModifiedDate":2020-04-13T00:54:27.873Z,"webkitRelativePath":""},
200
+ {origin:75,$h_mounted00:null,$scope:77,$parentScopes:78,$struct:80,$renders:90,$mounted:true,$renderid:+2,complete:true,width:+120,height:+120},
201
+ {$key:+0,$item:75,$index:+0,m:75},
202
+ [6,79],
203
+ {$key:+3,$item:74,$index:+3,i:+3,g:74,$origin:74},
204
+ {emits:81,waits:82,if:,repeat:,copys:83,binds:86,attrs:87,props:88,ids:89,once:},
205
+ {},
206
+ {},
207
+ [84,85],
208
+ {namespaceURI:null,prefix:null,localName:"height",name:"height",value:"120",ownerElement:76,specified:true},
209
+ {namespaceURI:null,prefix:null,localName:"width",name:"width",value:"120",ownerElement:76,specified:true},
210
+ {},
211
+ {},
212
+ {height:+120,width:+120},
213
+ [],
214
+ [],
215
+ [92,108],
216
+ {target:93,name:"mirror.png",lastModified:+1674329306397,"lastModifiedDate":2023-01-21T19:28:26.397Z,"webkitRelativePath":""},
217
+ {origin:92,$h_mounted00:null,$scope:94,$parentScopes:95,$struct:97,$renders:107,$mounted:true,$renderid:+2,complete:true,width:+120,height:+120},
218
+ {$key:+0,$item:92,$index:+0,m:92},
219
+ [6,96],
220
+ {$key:+4,$item:91,$index:+4,i:+4,g:91,$origin:91},
221
+ {emits:98,waits:99,if:,repeat:,copys:100,binds:103,attrs:104,props:105,ids:106,once:},
222
+ {},
223
+ {},
224
+ [101,102],
225
+ {namespaceURI:null,prefix:null,localName:"height",name:"height",value:"120",ownerElement:93,specified:true},
226
+ {namespaceURI:null,prefix:null,localName:"width",name:"width",value:"120",ownerElement:93,specified:true},
227
+ {},
228
+ {},
229
+ {height:+120,width:+120},
230
+ [],
231
+ [],
232
+ {target:109,name:"cat.jpg",lastModified:+1674329302876,"lastModifiedDate":2023-01-21T19:28:22.876Z,"webkitRelativePath":""},
233
+ {origin:108,$h_mounted00:null,$scope:110,$parentScopes:95,$struct:111,$renders:121,$mounted:true,$renderid:+2,complete:true,width:+120,height:+120},
234
+ {$key:+1,$item:108,$index:+1,m:108},
235
+ {emits:112,waits:113,if:,repeat:,copys:114,binds:117,attrs:118,props:119,ids:120,once:},
236
+ {},
237
+ {},
238
+ [115,116],
239
+ {namespaceURI:null,prefix:null,localName:"height",name:"height",value:"120",ownerElement:109,specified:true},
240
+ {namespaceURI:null,prefix:null,localName:"width",name:"width",value:"120",ownerElement:109,specified:true},
241
+ {},
242
+ {},
243
+ {height:+120,width:+120},
244
+ [],
245
+ [],
246
+ [123,139],
247
+ {target:124,name:"mirror.png",lastModified:+1742618719560,"lastModifiedDate":2025-03-22T04:45:19.560Z,"webkitRelativePath":""},
248
+ {origin:123,$h_mounted00:null,$scope:125,$parentScopes:126,$struct:128,$renders:138,$mounted:true,$renderid:+2,complete:true,width:+120,height:+120},
249
+ {$key:+0,$item:123,$index:+0,m:123},
250
+ [6,127],
251
+ {$key:+5,$item:122,$index:+5,i:+5,g:122,$origin:122},
252
+ {emits:129,waits:130,if:,repeat:,copys:131,binds:134,attrs:135,props:136,ids:137,once:},
253
+ {},
254
+ {},
255
+ [132,133],
256
+ {namespaceURI:null,prefix:null,localName:"height",name:"height",value:"120",ownerElement:124,specified:true},
257
+ {namespaceURI:null,prefix:null,localName:"width",name:"width",value:"120",ownerElement:124,specified:true},
258
+ {},
259
+ {},
260
+ {height:+120,width:+120},
261
+ [],
262
+ [],
263
+ {target:140,name:"cat.jpg",lastModified:+1742618719558,"lastModifiedDate":2025-03-22T04:45:19.558Z,"webkitRelativePath":""},
264
+ {origin:139,$h_mounted00:null,$scope:141,$parentScopes:126,$struct:142,$renders:152,$mounted:true,$renderid:+2,complete:true,width:+120,height:+120},
265
+ {$key:+1,$item:139,$index:+1,m:139},
266
+ {emits:143,waits:144,if:,repeat:,copys:145,binds:148,attrs:149,props:150,ids:151,once:},
267
+ {},
268
+ {},
269
+ [146,147],
270
+ {namespaceURI:null,prefix:null,localName:"height",name:"height",value:"120",ownerElement:140,specified:true},
271
+ {namespaceURI:null,prefix:null,localName:"width",name:"width",value:"120",ownerElement:140,specified:true},
272
+ {},
273
+ {},
274
+ {height:+120,width:+120},
275
+ [],
276
+ [],
277
+ [154,155],
278
+ {name:"陈一发儿.jpg",lastModified:+1742785178480,"lastModifiedDate":2025-03-24T02:59:38.480Z,"webkitRelativePath":""},
279
+ {name:"花粥.jpeg",lastModified:+1742785178478,"lastModifiedDate":2025-03-24T02:59:38.478Z,"webkitRelativePath":""}`);
280
+ assert(seek(data, '0.length'), 2);
281
+ assert(seek(data, '0.0.name'), '花粥.jpeg');
282
+ assert(seek(data, '0.0.target.$scope.$item.name'), '花粥.jpeg');
283
+ assert(seek(data, '0.1.name'), '陈一发儿.jpg');
284
+ assert(seek(data, '0.1.target.$scope.$item.name'), '陈一发儿.jpg');
285
+ assert(seek(data, '1.length'), 1);
286
+ assert(seek(data, '1.0.name'), 'ucbr.png');
287
+ assert(seek(data, '2.length'), 1);
288
+ assert(seek(data, '2.0.name'), 'kuwo.png');
289
+ assert(seek(data, '3.length'), 1);
290
+ assert(seek(data, '3.0.name'), 'icon.png');
291
+ assert(seek(data, '4.length'), 2);
292
+ assert(seek(data, '4.0.name'), 'mirror.png');
293
+ assert(seek(data, '4.1.name'), 'cat.jpg');
294
+ assert(seek(data, '5.length'), 2);
295
+ assert(seek(data, '5.0.name'), 'mirror.png');
296
+ assert(seek(data, '5.1.name'), 'cat.jpg');
297
+ assert(seek(data, '6.length'), 2);
298
+ assert(seek(data, '6.0.name'), '陈一发儿.jpg');
299
+ assert(seek(data, '6.1.name'), '花粥.jpeg');
300
+
301
+ }
54
302
  function test2(obj) {
55
303
  var data = JSAM.parse(JSON.stringify(obj));
56
- console.log(data);
304
+ if (!assert(data, obj)) console.log(data);
57
305
  }
58
306
  function test_json() {
59
307
  test2({ 1: 2 });
@@ -81,9 +329,11 @@ function test_time() {
81
329
  console.log(t1, t2, t3, t4);
82
330
  }
83
331
  function JSAM_test() {
84
- JSAM.debug = true;
85
332
  test_self();
86
333
  test_json();
334
+ JSAM.debug = true;
335
+ test_deep();
336
+ test_parse();
87
337
  JSAM.debug = false;
88
338
  test_time();
89
339
  }
@@ -51,6 +51,7 @@ var colorString = function (s, color1, e, color2) {
51
51
  else s += c1;
52
52
  return s;
53
53
  }
54
+ var ros = [], eos = [];
54
55
  var assert = function (result, expect, log = dump) {
55
56
  var errors = {}, hasCollect;
56
57
  var collect = function (k, args) {
@@ -64,9 +65,8 @@ var assert = function (result, expect, log = dump) {
64
65
  var color3 = format("<cyan>;</cyan>").split(";");
65
66
  mark.setTag1(color1[1], color1[0]);
66
67
  mark.setTag2(color2[1], color2[0]);
67
- var [r, e] = mark.pair(result, expect);
68
+ var [r, e] = mark.pair(String(result), String(expect));
68
69
  var s = r;
69
- if (typeof s === 'object') console.log(typeof s, s);
70
70
 
71
71
  r = colorString(r, color1, e, color2);
72
72
  e = colorString(e, color2, s, color1);
@@ -84,7 +84,7 @@ var assert = function (result, expect, log = dump) {
84
84
  };
85
85
  };
86
86
  var res = false;
87
- if (result === expect) {
87
+ if (result === expect || result !== result && expect !== expect) {
88
88
  res = true;
89
89
  }
90
90
  else if (typeof result === "number" && typeof expect === "number") {
@@ -105,8 +105,18 @@ var assert = function (result, expect, log = dump) {
105
105
  res = expect(result, (...args) => (b) => assert(result.apply(null, args), b, collect(b, args)), collect(`()`)) !== false;
106
106
  } else if (isObject(expect) && isObject(result)) {
107
107
  var res = true;
108
- for (var k in expect) {
109
- res = res && assert(result[k], expect[k], collect(k));
108
+ var ri = ros.indexOf(result);
109
+ var ei = eos.indexOf(expect);
110
+ if (ri !== ei) {
111
+ var color3 = format('<cyan>;</cyan>').split(";");;
112
+ res = false; collect(k)(`${color3.join("引用" + ri)} 应为 ${color3.join("引用" + ei)}`);
113
+ }
114
+ else if (ri === -1) {
115
+ ros.push(result);
116
+ eos.push(expect);
117
+ for (var k in expect) {
118
+ res = res && assert(result[k], expect[k], collect(k));
119
+ }
110
120
  }
111
121
  }
112
122
  if (!res) {
@@ -116,4 +126,9 @@ var assert = function (result, expect, log = dump) {
116
126
  }
117
127
  return res;
118
128
  }
119
- module.exports = assert;
129
+ module.exports = function (result, expect, dump) {
130
+ var res = assert(result, expect, dump);
131
+ ros = [];
132
+ eos = [];
133
+ return res;
134
+ };
@@ -11,12 +11,67 @@ var cloneChildNodes = function (template) {
11
11
  }
12
12
  return cNodes;
13
13
  }
14
+ var getitem = function (i) {
15
+ var src = this.src;
16
+ if (!src || i > src.length) return;
17
+ if (isFunction(src.get)) return src.get(i);
18
+ else return src[i];
19
+ }
20
+ var setitem = function (i, v) {
21
+ var src = this.src;
22
+ if (!src || i > src.length) return;
23
+ if (isFunction(src.set)) return src.set(i);
24
+ else return src[i] = v;
25
+ }
26
+ var createScope = function (container, index, com) {
27
+ var parsedSrc = container.$src;
28
+ var wraped = undefined;
29
+ var origin = com;
30
+ if (container.$wrapItem) {
31
+ com = container.$wrapItem(com);
32
+ }
33
+ if (com.constructor === Item) {
34
+ wraped = com;
35
+ com = com.value;
36
+ } else {
37
+ }
38
+ if (parsedSrc) {
39
+ var newScope = parsedSrc.createScope(com, index, index, wraped);
40
+ } else {
41
+ var newScope = container.src[index];
42
+ if (!isObject(newScope)) newScope = {
43
+ get $item() {
44
+ return getitem.call(container, this.$index);
45
+ },
46
+ set $item(v) {
47
+ return setitem.call(container, this.$index, v);
48
+ },
49
+ $key: index,
50
+ $index: index,
51
+ toString() {
52
+ return this.$item;
53
+ },
54
+ valueOf() {
55
+ return this.$item;
56
+ }
57
+ }
58
+ if (wraped) newScope.$wraped = wraped;
59
+ }
60
+ newScope.$origin = origin;
61
+ return newScope;
62
+ }
63
+ var update = function (scope, index) {
64
+ var item = getitem.call(this, index);
65
+ if (!isHandled(item) || item === scope.$origin) return;
66
+ var newScope = createScope(this, index, item);
67
+ extend(scope, newScope);
68
+ }
14
69
 
15
70
  /**
16
71
  * @param {Element} container
17
72
  * @param {Element|string} tagName;
18
73
  */
19
- var getGenerator = function (container, tagName = 'item') {
74
+ var getGenerator = function (container, tagName = 'item', wrapItem = false) {
20
75
  if (!container) return;
21
76
  var scopes = container.$parentScopes || [];
22
77
  if (container.$scope) scopes = scopes.concat(container.$scope);
@@ -26,6 +81,9 @@ var getGenerator = function (container, tagName = 'item') {
26
81
  var tagTemplate = isElement(tagName);
27
82
  var templates = [];
28
83
  var hasAfter = false;
84
+ if (wrapItem) {
85
+ container.$wrapItem = isFunction(wrapItem) ? wrapItem : Item;
86
+ }
29
87
  for (let a of container.childNodes) {
30
88
  if (a.nodeType === 1 && a.hasAttribute('insert')) {
31
89
  if (!templates.length) a.$isbefore = true;
@@ -67,10 +125,7 @@ var getGenerator = function (container, tagName = 'item') {
67
125
  */
68
126
  return container.$generator = function (index, com, element) {
69
127
  if (com === undefined) {
70
- var src = container.src;
71
- if (!src || index >= src.length) return;
72
- if (isFunction(src.get)) com = src.get(index);
73
- else com = src[index];
128
+ com = getitem.call(container, index);
74
129
  }
75
130
  if (com === undefined) return;
76
131
  if (isNode(element));
@@ -83,37 +138,10 @@ var getGenerator = function (container, tagName = 'item') {
83
138
  if (childNodes.length > 1) element.with = Array.prototype.slice.call(childNodes, 1);
84
139
  }
85
140
  var scopes = container.$generatorScopes;
86
- var parsedSrc = container.$src;
87
- var wraped = undefined;
88
- if (com instanceof Item) {
89
- wraped = com;
90
- com = com.value;
91
- }
92
- if (parsedSrc) {
93
- var newScope = parsedSrc.createScope(com, index, index, wraped);
94
- } else {
95
- var newScope = container.src[index];
96
- if (!isObject(newScope)) newScope = {
97
- get $item() {
98
- return container.src[this.$index];
99
- },
100
- set $item(v) {
101
- container.src[this.$index] = v;
102
- this.value = v;
103
- },
104
- $key: index,
105
- $index: index,
106
- toString() {
107
- return this.$item;
108
- },
109
- valueOf() {
110
- return this.$item;
111
- }
112
- }
113
- if (wraped) newScope.$wraped = wraped;
114
- }
141
+ var newScope = createScope(container, index, com);
115
142
  element.$scope = newScope;
116
143
  element.$parentScopes = scopes;
144
+ element.$renders = [update.bind(container, newScope, index)];
117
145
  var newItem = render(element, newScope, scopes, false);
118
146
  if (element.with) newItem.with = render(element.with, newScope, scopes, false);
119
147
  return newItem;
@@ -284,11 +284,7 @@ function main() {
284
284
  ItemTemplate.setAttribute("e-class", className);
285
285
  if (src.itemName) ItemTemplate.setAttribute("e-if", notHidden);
286
286
  ItemTemplate.innerHTML = menuItem.template;
287
- var generator = getGenerator(page, ItemTemplate);
288
- page.$generatorScopes.push($scope);
289
- list(page, function (index) {
290
- var item = items[index];
291
- if (!item) return;
287
+ var generator = getGenerator(page, ItemTemplate, (item) => {
292
288
  if (item.constructor !== Item) item = new Item(item);
293
289
  if (istoolbar) {
294
290
  if (item.constructor === Item && item.length && !item.extended) {
@@ -296,8 +292,11 @@ function main() {
296
292
  item.value = Object.assign({}, item.value);
297
293
  }
298
294
  }
299
- return generator(index, item);
300
- }, direction);
295
+ return item;
296
+ });
297
+ page.$generatorScopes.push($scope);
298
+ page.src = items;
299
+ list(page, generator, direction);
301
300
  if (!page.$renders) page.$renders = [];
302
301
  page.$renders.unshift(function () {
303
302
  this.$scope.hasIcon = hasIcon();
@@ -113,7 +113,7 @@ function getWatchData(element) {
113
113
  var props = {};
114
114
  for (var key in $watches) {
115
115
  var data = element[key];
116
- props[key] = isObject(data) && !isFunction(data) && !isDate(data) && !isNode(data) ? extend(data instanceof Array ? [] : {}, data) : data;
116
+ props[key] = data;
117
117
  }
118
118
  return props;
119
119
  }
@@ -130,7 +130,7 @@ function rebuild(element, isFirstRender) {
130
130
  for (var k in props) {
131
131
  var current = element[k];
132
132
  var previous = props[k];
133
- if (shallowEqual(current, previous)) continue;
133
+ if (isSame(current, previous)) continue;
134
134
  if (!capture) capture = {};
135
135
  capture[k] = { current, previous };
136
136
  }
@@ -585,17 +585,34 @@ var createBinder2 = function (write, read) {
585
585
 
586
586
  var src2 = function (search) {
587
587
  var getter = createGetter(this, search);
588
- var savedValue;
588
+ var checkArrayProperties = /^\[[^\]]+\]$/.test(search);
589
+ var savedValue, savedLength;
590
+ // 非直传数组的数据源变动后,不再检查其所有属性是否相同,直接同步到组件,
591
+ // 直传数组的数据源以数组中的子项是否变动为准,
592
+ // 直传数组的判别标准为表达式以“[”开头以“]”结尾,且表达式中间不含“]”
589
593
  this.$renders.push(function () {
590
594
  var origin = getter(this);
591
- var temp = shallowClone(origin);
592
- if (isHandled(savedValue)) {
593
- if (shallowEqual(temp, savedValue, 1)) return;
595
+ if (isArray(origin)) {
596
+ if (isArray(savedValue)) {
597
+ if (isSame(origin, savedValue)) {
598
+ if (origin.length === savedLength) return;
599
+ }
600
+ else {
601
+ a: if (checkArrayProperties && origin.length === savedLength) {
602
+ for (var cx = 0, dx = savedLength; cx < dx; cx++) {
603
+ if (savedValue[cx] !== origin[cx]) break a;
604
+ }
605
+ return;
606
+ }
607
+ }
608
+ }
609
+ savedLength = origin.length;
610
+ savedValue = origin;
594
611
  }
595
612
  else {
596
- if (isSame(savedValue, temp)) return;
613
+ if (isSame(savedValue, origin)) return;
614
+ savedValue = origin;
597
615
  }
598
- savedValue = temp;
599
616
  if (!isHandled(origin) && !isHandled(this.src));
600
617
  else this.src = origin;
601
618
  cast(this, origin);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "4.22.16",
3
+ "version": "4.22.18",
4
4
  "description": "一个开发环境,提供一种自由的前端开发模式,也可作为辅助工具使用。",
5
5
  "main": "public/efront.js",
6
6
  "directories": {