efront 3.34.3 → 3.34.6

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.
Files changed (41) hide show
  1. package/apps/kugou/favicon.ico +0 -0
  2. package/apps/kugou/home.js +1 -1
  3. package/apps/kugou/ie8.js +93 -0
  4. package/apps/kugou/index.html +5 -2
  5. package/apps/kugou/search/search.js +5 -3
  6. package/coms/basic/#decrypt.js +1 -0
  7. package/coms/basic/#loader.js +26 -14
  8. package/coms/basic/ArrayFill.js +1 -1
  9. package/coms/basic/JSAM.js +7 -3
  10. package/coms/basic/parseURL.js +49 -13
  11. package/coms/basic/parseURL_test.js +6 -1
  12. package/coms/basic/renderExpress.js +1 -1
  13. package/coms/basic_/Array2.js +1 -1
  14. package/coms/basic_/Promise.js +21 -14
  15. package/coms/basic_/[]map.js +27 -3
  16. package/coms/basic_/readme.md +83 -0
  17. package/coms/kugou/api.js +2 -2
  18. package/coms/kugou/bindScroll.js +0 -1
  19. package/coms/kugou/buildScroll.js +1 -0
  20. package/{apps → coms}/kugou/icons/kugo.ico +0 -0
  21. package/{apps → coms}/kugou/icons/kuwo.png +0 -0
  22. package/coms/kugou/icons/qqjt.ico +0 -0
  23. package/{apps → coms}/kugou/icons/yyyy.ico +0 -0
  24. package/coms/kugou/page.js +6 -3
  25. package/coms/kugou/playList.html +1 -1
  26. package/coms/kugou/playList.js +1 -0
  27. package/coms/kugou/player.html +3 -3
  28. package/coms/kugou/player.js +5 -4
  29. package/coms/zimoli/LoadingArray.js +9 -25
  30. package/coms/zimoli/appendChild.js +1 -1
  31. package/coms/zimoli/data.js +16 -6
  32. package/coms/zimoli/gallery.js +1 -1
  33. package/coms/zimoli/getGenerator.js +1 -1
  34. package/coms/zimoli/on.js +2 -0
  35. package/coms/zimoli/render.js +33 -33
  36. package/coms/zimoli/selectList.js +1 -1
  37. package/coms/zimoli/zimoli.js +4 -0
  38. package/package.json +1 -1
  39. package/public/efront.js +1 -1
  40. package/readme.md +8 -8
  41. package/apps/kugou/icons/qqjt.ico +0 -0
@@ -0,0 +1,83 @@
1
+ # efront 兼容性说明
2
+ * `coms/basic_`目录的代码均为非标准实现,如果你要兼容低版本的运行环境,尽量避免使用高级的功能
3
+ * 已知在转换成低版本代码后与高级版本有区别的语法如下:
4
+ 1. ```javascript
5
+ class ... extends Array {...}
6
+ ```
7
+ 因为如果增加一级原型,数组的特性便会消失,`efront`暂时并没有实现完美的降级方案,未来实现的可能性也不大。类似语句经`typescript`转换后新定义的方法会丢失, `efront` 在降级编译期使用 `class ... extends Array2 {...}` 进行替换,`Array2`会将定义的方法挂载到新生成的对象上。
8
+
9
+ 2. ```javascript
10
+ async function () {
11
+ await ...;
12
+ arguments; // typescript 转换后arguments对象的内容有误
13
+ }
14
+ // 或
15
+ function* (){
16
+ yield ...;
17
+ arguments;
18
+ }
19
+ ```
20
+ 这不是一个难解决的问题,应该只是`typescript`已发现但不愿解决的问题。`efront`在降级编译时临时使用变量重命名的方法对代码中的`arguments`进行替换使其内容与原生高级代码一致。
21
+
22
+ 3. ```javascript
23
+ Object.keys
24
+ Object.create
25
+ Array.prototype.map
26
+ Array.prototype.forEach
27
+ Array.prototype.filter
28
+ Array.prototype.indexOf
29
+ String.prototype.trim// 不同的支持环境实现不一致,大厂对空格的理解不一致
30
+ Function.prototype.bind
31
+ ```
32
+ 以上几个方法`ie9+`系列浏览器已支持,但`ie8`及以下版本不支持,如果没有指定`--no-polyfill`参数`efront`在降级编译期会使用`[]map.js`中提供的方法进行修补,这些方法会在加载器检测到浏览器不支持`[].map`时进行初始化
33
+ 4. ```javascript
34
+ Object.assign
35
+ Array.prototype.fill
36
+ ```
37
+ 以上两个原生方法`ie`系列浏览器均不支持,由于经常被`efront`开发者使用,在降级编译期,如果没有指定`--no-polyfill`参数,将由`efront`处理成替代品,当前的处理方案如下:
38
+ ```javascript
39
+ Object.assign // 由 extend 替代,见 ../basic/extend.js
40
+ Array.prototype.fill //..将按使用的目的进行不同的替换
41
+ Array(3).fill(0) // 类似这种的将变成[0,0,0]一个常量数组
42
+ var [a,b,c]=Array(3).fill(0).map((_,i)=>i+1) // 类似这种用于生成常量并赋值的,将直接变成赋值语句 var a=1,b=2,c=3
43
+ Array(3).fill(a)// 类似这种非常量的,将由类似 ArrayFill(3,a) 的语句替换
44
+ ```
45
+ 5. ```javascript
46
+ Promise
47
+ Promise.prototype.then
48
+ Promise.prototype.catch
49
+ Promise.all
50
+ Promise.race
51
+ Promise.reject
52
+ Promise.resolve
53
+ ```
54
+ `Promise`对象也是`ie`系列浏览器均不支持的。`efront`实现的`Promise`与原生的特性并不一致,仅在运行环境不支持的时候进行替代。比如由`.then`触发的方法与`setTimeout`触发的方法执行的先后顺序会与高级的运行环境有所区别,但也会保持在当前语境执行后再执行相关的语句。以上没有提到的`Promise`相关的方法均不支持,如`Promise.prototype.finally`,如果您使用了这些缺失的特性,就只能自己实现或找类似[core-js](https://github.com/zloirock/core-js)的库填充了
55
+ 6. ```javascript
56
+ obj.if
57
+ obj.catch
58
+ obj.for
59
+ ```
60
+ 类似这种用`.`取属性的语句,由于属性名与`js`的保留字一样,`ie6`等浏览器会报错,但您可以在`efront`提供的环境中放心使用。因为`efront`本身就会把取属性的语句处理掉。
61
+ 7. `ie8`及以下浏览器中存在的一些与现代`js`标准不同的特性,`efront`提供的组件可能不兼容,在处理为这类环境进行应用开发时,应避免使用。
62
+ ```javascript
63
+ Object.defineProperty(...);
64
+ ({
65
+ get a(){},
66
+ set a(){}
67
+ });
68
+ class {
69
+ get a(){}
70
+ set a(){}
71
+ }
72
+ ```
73
+ `ie8`及以下浏览器对`Object.defineProperty`支持的不好或根本不支持,`efront`暂时没有实现这类功能的兼容方案。如果您要兼容相应的环境,请暂时避免使用相关的语句,也不要使用使用了这些特性的库。
74
+ ```javascript
75
+ Array.prototype.slice.call(objNodeList,...)
76
+ ```
77
+ `ie8`及以下浏览器不支持`this`指向`NodeList`等dom对象,而当前`efront`和内部使用的`typescript`转换的代码都没有处理这一细节,所以暂时不要在dom操作相关的语句中使用高级语法,以避免转换后的代码出问题。
78
+ ```javascript
79
+ var div = document.createElement("div");
80
+ div.innerHTML = `<abcd><span></span></abcd>`;
81
+ console.log(div.innerHTML); // <SPAN></SPAN>
82
+ ```
83
+ `ie8`及以下浏览器无法正确地通过`innerHTML`属性设置自定义标签,`efront`提供的大部分组件都使用了这一特性,`efront`示例项目中[ie8.js](../../apps/kugou/ie8.js)可以实现`ie8`上设置`innerHTML`的适配,但不能保证样式正常,对于`ie7`及以下的浏览器,就暂时别用`efront`提供的与元素相关的组件了。
package/coms/kugou/api.js CHANGED
@@ -3,8 +3,8 @@
3
3
  "song-info;hash": "get app/i/getSongInfo.php?cmd=playInfo&from=mkugou",
4
4
  "slider-src": "get:[].mod-slider>.swipe-wrap>div .#src=img!src&href=a!href",
5
5
  "songs-list": "get:[].panel-songslist%20li .#hash=!id&.panel-songs-item-name>span!innerText",
6
- "songs-list": "get:[].m_cm_item1warp:nth-child(2)>div .#=a!href\\song-mix&a:nth-child(2)>p:first-child!innerText&singer=a:nth-child(2)>p:nth-child(2)!innerText&imgurl=img!_src",
7
- "song-mix;": "mget:script:nth-last-child(2) mixsong/:hashid.html",
6
+ "songs-list": "get:[]div+.m_cm_item1warp>div .#=a!href\\song-mix&a+a>p:first-child!innerText&singer=a+a>p+p!innerText&imgurl=img!_src",
7
+ "song-mix;": "mget:script+script mixsong/:hashid.html",
8
8
  "rank-list": "get:[].panel-img-list%20li rank/list#href=a!href&=a!href\\rank-info&imgurl=img!_src&name=p|innerText",
9
9
  "rank-info": "get:[].panel-songslist%20li rank/info/:id#src=!id&name=.panel-songs-item-name|innerText&data=.panel-songs-item-download/innerText",
10
10
  "rank-title": "get:.page-title rank/info/:id#title=!innerText",
@@ -26,7 +26,6 @@ function bindScroll(titlebar, page) {
26
26
  if (!image.style.backgroundImage && !/img/i.test(image.className)) return;
27
27
  return image;
28
28
  }
29
-
30
29
  onmounted(page, function () {
31
30
  css(titlebar, `min-height:${fromPixel(topHeight)}`);
32
31
  var image = getImage();
@@ -1,5 +1,6 @@
1
1
  function Main(dataid, datapath, titleid) {
2
2
  var _titlebar = titlebar(" ");
3
+ state.with(_titlebar);
3
4
  var page = createVboxWithState(state);
4
5
  page.initialStyle = 'margin-left:100%';
5
6
  page.innerHTML = buildScroll;
File without changes
File without changes
Binary file
File without changes
@@ -56,11 +56,14 @@ var bar = createBottomBar({
56
56
  [i18n("看", "Watch")]: "/kugou/view:请输入房间号、主播昵称",
57
57
  [i18n("唱", "Sing")]: "/kugou/sing:今天想唱什么歌",
58
58
  });
59
- var menu_btn = button("<i>&#xe6d4;</i>", "left");
59
+ var menu_btn = button("", "left");
60
+ menu_btn.innerHTML='<i>&#xe6d4;</i>';
60
61
  onclick(menu_btn, kugou$dragview.toChange);
61
- var plus_btn = button("<i>&#xe632;</i>", "right");
62
+ var plus_btn = button("", "right");
63
+ plus_btn.innerHTML = '<i>&#xe632;</i>';
62
64
  select(plus_btn, kugou$plusmenu());
63
- var search_btn = button("<i>&#xe60d;</i> <info>搜索</info>", "search");
65
+ var search_btn = button("", "search");
66
+ search_btn.innerHTML = '<i>&#xe60d;</i> <info>搜索</info>';
64
67
  onclick(search_btn, function () {
65
68
  go("/kugou/search");
66
69
  });
@@ -7,7 +7,7 @@
7
7
  <song ng-click="play(i)" ng-class="{activate:musicList.isActived(p)}" ng-src=p></song>
8
8
  </padding>
9
9
  </list>
10
- <div foot>
10
+ <div foot -if="wakeEnabled">
11
11
  <span>播放时屏幕常亮</span>&nbsp;&nbsp;
12
12
  <swap -model="playMode.wake" @change="keepWake"></swap>
13
13
  </div>
@@ -10,6 +10,7 @@ var $scope = {
10
10
  song: kugou$song,
11
11
  padding,
12
12
  swap,
13
+ wakeEnabled: !!document.addEventListener,
13
14
  mode: playModes[playModeIndex],
14
15
  switchMode() {
15
16
  playModeIndex++;
@@ -11,9 +11,9 @@
11
11
  <span ng-bind="totalTime"></span>
12
12
  </div>
13
13
  <div class="song">
14
- <span class="name" ng-bind=songName></span>
15
- <span class="spliter" ng-if="songName&&singerName">&nbsp;-&nbsp;</span>
16
- <span class="singer" ng-bind=singerName></span>
14
+ <span class="name" ng-bind=getSongName()></span>
15
+ <span class="spliter" ng-if="getSongName()&&getSingerName()">&nbsp;-&nbsp;</span>
16
+ <span class="singer" ng-bind=getSingerName()></span>
17
17
  </div>
18
18
  </div>
19
19
  <btn class="prev" ng-click=play(index-1)></btn>
@@ -137,10 +137,10 @@ var $scope = {
137
137
  canvas: kugou$dance,
138
138
  activeList: playList,
139
139
  index: 0,
140
- get songName() {
140
+ getSongName() {
141
141
  return this.info.singername || this.info.singerName;
142
142
  },
143
- get singerName() {
143
+ getSingerName() {
144
144
  return this.info.songname || this.info.songName;
145
145
  },
146
146
  update() {
@@ -327,7 +327,7 @@ var $scope = {
327
327
  };
328
328
  delete playState.error;
329
329
  if (ns.wake) ns.enable();
330
- _audio.src = hasContext && music.type === "kugo" ? cross.getCrossUrl(response.url) : response.url;
330
+ _audio.src = hasContext && music.type !== "qqjt" ? cross.getCrossUrl(response.url) : response.url;
331
331
  _audio.play();
332
332
  data.setInstance('musicList', distlist, true);
333
333
  render.refresh();
@@ -431,8 +431,9 @@ var createControls = function () {
431
431
  });
432
432
  return player;
433
433
  };
434
- var ns = new thirdParty$NoSleep;
434
+ var ns = document.addEventListener && new thirdParty$NoSleep;
435
435
  data.bindInstance("play-mode", function (e) {
436
+ if (!ns) return;
436
437
  if (e.wake) {
437
438
  ns.wake = true;
438
439
  if ($scope.playing) {
@@ -1,25 +1,9 @@
1
- // class LoadingArray extends Array {
2
- // totalCount = 0;
3
- // data = [];
4
- // is_errored = null;
5
- // error_message = null;
6
- // is_loading = true;
7
- // is_loaded = false;
8
- // is_readonly = null;
9
- // loading = null;
10
- // loading_promise = null;
11
- // then (ok, oh) {
12
- // if (this.loading_promise) this.loading_promise.then(ok, oh);
13
- // }
14
- // }
15
- function LoadingArray() {
16
- var this0 = [];
17
- this0.is_errored = null;
18
- this0.error_message = null;
19
- this0.is_loading = true;
20
- this0.is_loaded = false;
21
- this0.is_readonly = null;
22
- this0.loading = null;
23
- this0.loading_promise = null;
24
- return this0;
25
- };
1
+ class LoadingArray extends Array {
2
+ is_errored = null;
3
+ error_message = null;
4
+ is_loading = true;
5
+ is_loaded = false;
6
+ is_readonly = null;
7
+ loading = null;
8
+ loading_promise = null;
9
+ }
@@ -15,7 +15,7 @@ function _onappend(node, append = createEvent("append"), mount = createEvent("mo
15
15
  if (node.isMounted) return;
16
16
  if (node.nodeType === 1 || node.nodeType === 8) node.isMounted = true;
17
17
  dispatch(node, append);
18
- var children = [...node.childNodes];
18
+ var children = Array.apply(null, node.childNodes);
19
19
  for (var c of children) {
20
20
  _onappend(c, append, mount);
21
21
  }
@@ -210,7 +210,7 @@ function seekResponse(data, seeker, apiMap = {}) {
210
210
  seeker = unescape(seeker);
211
211
  var reg = /^(\[\]|,)|(\[\]|,)$/g;
212
212
  if (reg.test(seeker)) {
213
- return [].concat.apply([], data.querySelectorAll(seeker.replace(reg, '')));
213
+ return Array.apply(null, data.querySelectorAll(seeker.replace(reg, '')));
214
214
  }
215
215
  var reg = /[\|\?\!\/]/, selector, prop;
216
216
  if (reg.test(seeker)) {
@@ -321,17 +321,27 @@ var parseData = function (sourceText) {
321
321
  return new window.DOMParser().parseFromString(sourceText, "text/html");
322
322
  }
323
323
  // XML 格式
324
- var doc = document.implementation.createHTMLDocument('');
324
+ var { implementation } = document;
325
+ if (implementation.createHTMLDocument) var doc = implementation.createHTMLDocument("");
326
+ else {
327
+ doc = document.createElement("html");
328
+ doc.head = document.createElement("head");
329
+ doc.body = document.createElement("body");
330
+ doc.appendChild(doc.head);
331
+ doc.appendChild(doc.body);
332
+ doc.documentElement = doc;
333
+ }
325
334
  if (isWorseIE) {
326
335
  sourceText = sourceText
327
336
  .replace(/<!--[\s\S]*?-->|<\[CDATA\[[\s\S]*?\]\]>/ig, '')
328
337
  .replace(/^[\s\S]*?<html>([\s\S]*)<\/html>[\s\S]*?$/i, '$1')
329
338
  .replace(/^([\s\S]*?)<body>([\s\S]*?)$/i, '$1<body>$2')
330
- .replace(/<\/body>[\s\S]*?$/, '');
331
- var div = document.createElement('div');
332
- div.innerHTML = sourceText.replace(/^([\s\S]*?)<body>[\s\S]*?$/, "$1")
339
+ .replace(/<\/body>[\s\S]*?$/, '')
340
+ .replace(/<(script|style)[\s\>][\s\S]*?<\/\1>/ig, '');
341
+ var hd = document.createElement('div');
342
+ hd.innerHTML = sourceText.replace(/^([\s\S]*?)<body>[\s\S]*?$/, "$1")
333
343
  .replace(/<head>/i, '').replace(/<\/head>/i, '');
334
- for (var c of [...div.childNodes]) doc.head.appendChild(c);
344
+ for (var c of Array.apply(null, hd.childNodes)) doc.head.appendChild(c);
335
345
  doc.body.innerHTML = sourceText.replace(/^[\s\S]*?<body>/, '');
336
346
  } else {
337
347
  doc.documentElement.innerHTML = sourceText;
@@ -67,7 +67,7 @@ function gallery(element, minWidth, generator) {
67
67
  var c = createColumn(cx);
68
68
  element.appendChild(c);
69
69
  }
70
- bindScroll([].slice.call(element.children, 0));
70
+ bindScroll(Array.apply(null, element.children));
71
71
 
72
72
  };
73
73
  element.go = function (index) {
@@ -7,7 +7,7 @@ var cloneChildNodes = function (template) {
7
7
  var tNodes = template.childNodes;
8
8
  for (var cx = 0, dx = cNodes.length; cx < dx; cx++) {
9
9
  cNodes[cx].$struct = tNodes[cx].$struct;
10
- cNodes[cx].renderid = tNodes[cx].renderid;
10
+ cNodes[cx].$renderid = tNodes[cx].$renderid;
11
11
  }
12
12
  return cNodes;
13
13
  }
package/coms/zimoli/on.js CHANGED
@@ -315,7 +315,9 @@ var checkroot = function (element, k) {
315
315
  if (!(k in element)) {
316
316
  if (element === window && k in document) {
317
317
  element = document;
318
+ // <!--
318
319
  if (!checkroot[k]) checkroot[k] = true, console.warn("使用 document 的", k, "替代 window 的");
320
+ // -->
319
321
  }
320
322
  }
321
323
  return element;
@@ -32,10 +32,10 @@ var createTemplateNodes = function (text) {
32
32
  } else {
33
33
  var node = document.createElement(this.parentNode.tagName || "div");
34
34
  node.innerHTML = text;
35
- this.with = [].slice.call(node.childNodes, 0);
35
+ this.with = Array.apply(null, node.childNodes);
36
36
  }
37
37
  appendChild.after(this, this.with);
38
- this.with = renderElement(this.with, this.$scope, this.$parentScopes, this.renderid === 9);
38
+ this.with = renderElement(this.with, this.$scope, this.$parentScopes, this.$renderid === 9);
39
39
  };
40
40
  presets.template = function (t) {
41
41
  var comment = document.createComment('template');
@@ -57,16 +57,16 @@ var renderidClosed = 0;
57
57
  var addRenderElement = function () {
58
58
  var element = this;
59
59
  if (!isNode(element)) return;
60
- if (element.renderid !== 9) {
60
+ if (element.$renderid !== 9) {
61
61
  // 只渲染一次
62
- if (element.renderid < 10 && element.renderid > 0) element.renderid = ++renderidOffset;
63
- renderElements[element.renderid] = element;
62
+ if (element.$renderid < 10 && element.$renderid > 0) element.$renderid = ++renderidOffset;
63
+ renderElements[element.$renderid] = element;
64
64
  }
65
65
  rebuild(element);
66
66
  };
67
67
  var removeRenderElement = function () {
68
68
  var element = this;
69
- delete renderElements[element.renderid];
69
+ delete renderElements[element.$renderid];
70
70
  };
71
71
  function refresh(root) {
72
72
  var rest = [];
@@ -130,15 +130,15 @@ var createComment = function (renders, type, expression) {
130
130
 
131
131
  var initialComment = function (comment) {
132
132
  if (!comment.$struct.once) {
133
- comment.renderid = ++renderidOffset;
133
+ comment.$renderid = ++renderidOffset;
134
134
  onmounted(comment, addRenderElement);
135
135
  onremove(comment, removeRenderElement);
136
136
  if (isMounted(comment) || eagermount) rebuild(comment);
137
137
  }
138
138
  else {
139
- comment.renderid = 9;
139
+ comment.$renderid = 9;
140
140
  rebuild(comment);
141
- delete comment.with;
141
+ if (comment.with) comment.with = null;
142
142
  remove(comment);
143
143
  }
144
144
  };
@@ -248,7 +248,7 @@ var createRepeat = function (search, id = 0) {
248
248
  }
249
249
  var clone = element.cloneNode();
250
250
  clone.innerHTML = element.innerHTML;
251
- clone.renderid = id;
251
+ clone.$renderid = id;
252
252
  clone.$scope = $scope;
253
253
  clone.$parentScopes = $parentScopes;
254
254
  clone.$struct = $struct;
@@ -300,7 +300,6 @@ var createIf = function (search, id = 0) {
300
300
  break;
301
301
  }
302
302
  }
303
- // console.log(shouldMount,savedValue,this,this.$scope)
304
303
  if (savedValue === shouldMount) return;
305
304
  savedValue = shouldMount;
306
305
  for (var cx = 0, dx = elements.length; cx < dx; cx += 2) {
@@ -308,8 +307,8 @@ var createIf = function (search, id = 0) {
308
307
  if (cx === shouldMount) {
309
308
  var e = c.$template;
310
309
  appendChild.after(c, e);
311
- if (e.renderid < 0) {
312
- e.renderid = id;
310
+ if (e.$renderid < 0) {
311
+ e.$renderid = id;
313
312
  e = c.$template = render(e, this.$scope, this.$parentScopes);
314
313
  e.$comment = c;
315
314
  }
@@ -722,21 +721,21 @@ function renderRest(element, struct, replacer = element) {
722
721
 
723
722
  function renderElement(element, scope = element.$scope, parentScopes = element.$parentScopes, once) {
724
723
  if (isArrayLike(element)) {
725
- return Array.prototype.slice.call(element).map(function (element) {
724
+ return Array.apply(null, element).map(function (element) {
726
725
  return renderElement(element, scope, parentScopes, once);
727
726
  });
728
727
  }
729
728
  if (!isElement(element)) {
730
729
  return element;
731
730
  }
732
- if (!isNumber(element.renderid)) {
733
- element.renderid = 0;
731
+ if (!isNumber(element.$renderid)) {
732
+ element.$renderid = 0;
734
733
  element.$scope = scope;
735
734
  if (!isEmpty(parentScopes) && !isArray(parentScopes)) {
736
735
  throw new Error('父级作用域链应以数组的类型传入');
737
736
  }
738
737
  if (parentScopes) {
739
- if (element.renderid && !element.$parentScopes || element.$parentScopes && element.$parentScopes.length !== parentScopes.length) {
738
+ if (element.$renderid && !element.$parentScopes || element.$parentScopes && element.$parentScopes.length !== parentScopes.length) {
740
739
  throw new Error("父作用域链的长度必须相等着");
741
740
  }
742
741
  }
@@ -746,25 +745,26 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
746
745
  if (isEmpty(s.once)) s.once = once;
747
746
  element.$eval = $eval;
748
747
  }
749
- if (element.renderid <= -1) element = renderStructure(element);
748
+ if (element.$renderid <= -1) element = renderStructure(element);
750
749
  if (!element) return;
751
- if (!element || element.renderid < 0 || element.nodeType !== 1) {
750
+ if (!element || element.$renderid < 0 || element.nodeType !== 1) {
752
751
  return element;
753
752
  }
754
753
  for (var id of element.$struct.ids) {
755
754
  if (scope[id] && scope[id] !== element) throw new Error("同一个id不能使用两次:" + id);
756
755
  scope[id] = element;
757
756
  }
758
- var isFirstRender = !element.renderid;
757
+ var isFirstRender = !element.$renderid;
758
+
759
759
  if (isFirstRender) {
760
- element.renderid = 1;
760
+ element.$renderid = 1;
761
761
  var parentNode = element.parentNode;
762
762
  if (parentNode) {
763
- if (parentNode.renderid > 1 || isMounted(parentNode)) element.renderid = 2;
763
+ if (parentNode.$renderid > 1 || isMounted(parentNode)) element.$renderid = 2;
764
764
  }
765
765
  element.renders = element.renders ? [].concat(element.renders) : [];
766
766
  var { copys, binds, once } = element.$struct;
767
- if (once) element.renderid = 9;
767
+ if (once) element.$renderid = 9;
768
768
  if (binds.src) {
769
769
  element.$src = parseRepeat(binds.src);
770
770
  }
@@ -784,7 +784,7 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
784
784
  if (isNode(replacer) && element !== replacer) {
785
785
  if (!replacer.$scope) replacer.$scope = scope;
786
786
  if (!replacer.$parentScopes) replacer.$parentScopes = parentScopes;
787
- if (isElement(replacer) && !replacer.renderid) {
787
+ if (isElement(replacer) && !replacer.$renderid) {
788
788
  createStructure(replacer);
789
789
  if (replacer.children && replacer.children.length) renderElement(replacer.children, replacer.$scope, replacer.$parentScopes, once);
790
790
  renderRest(replacer, replacer.$struct);
@@ -794,7 +794,7 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
794
794
  if (nextSibling) appendChild.before(nextSibling, replacer);
795
795
  else if (parentNode) appendChild(parentNode, replacer);
796
796
  if (element.parentNode === parentNode) remove(element);
797
- if (!replacer.renderid) replacer.renderid = element.renderid;
797
+ if (!replacer.$renderid) replacer.$renderid = element.$renderid;
798
798
  for (var id of element.$struct.ids) {
799
799
  scope[id] = replacer;
800
800
  }
@@ -818,10 +818,10 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
818
818
  element.$struct.ons.forEach(([on, key, value]) => on.call(element, element, key, value));
819
819
  }
820
820
  if (element.renders.length) {
821
- if (element.renderid !== 9) {
821
+ if (element.$renderid !== 9) {
822
822
  onmounted(element, addRenderElement);
823
823
  onremove(element, removeRenderElement);
824
- if (isMounted(element) || element.renderid > 1) addRenderElement.call(element);
824
+ if (isMounted(element) || element.$renderid > 1) addRenderElement.call(element);
825
825
  else if (eagermount) rebuild(element);
826
826
  }
827
827
  else {
@@ -876,7 +876,7 @@ function createStructure(element) {
876
876
  if (isArrayLike(element)) return Array.prototype.map.call(element, createStructure);
877
877
  if (element.$struct) return element.$struct;
878
878
  // 处理结构流
879
- var attrs = Array.prototype.slice.call(element.attributes);
879
+ var attrs = Array.apply(null, element.attributes);
880
880
  var types = {};
881
881
  var emiter_reg = /^(?:(v|ng|on|once)?\-|v\-on\:|@|once|on)/i;
882
882
  var ons = [];
@@ -888,6 +888,7 @@ function createStructure(element) {
888
888
  var ids = [];
889
889
  for (var attr of attrs) {
890
890
  var { name, value } = attr;
891
+ if (/^\$/.test(name)) continue;
891
892
  if (name === 'elementid' || name === 'renderid' || name === 'id') {
892
893
  ids.push(value);
893
894
  continue;
@@ -912,7 +913,7 @@ function createStructure(element) {
912
913
  }
913
914
  var key = name.replace(/^(ng|v|.*?)\-/i, "").toLowerCase();
914
915
  if (structures.hasOwnProperty(key)) {
915
- if (element.renderid <= -2) {
916
+ if (element.$renderid <= -2) {
916
917
  if (/^if$|^else/i.test(key)) {
917
918
  if (types.if) {
918
919
  throw new Error(`暂不支持在同一元素上使用多次if结构!`);
@@ -924,14 +925,13 @@ function createStructure(element) {
924
925
  }
925
926
  }
926
927
  if (/^if$|^else/i.test(key)) {
927
- types.if = attr;
928
- attr.key = key;
928
+ types.if = { key, name, value };
929
929
  }
930
930
  else {
931
931
  types.repeat = attr;
932
932
  }
933
- if (!element.renderid) element.renderid = -1;
934
- else element.renderid = -2;
933
+ if (!element.$renderid) element.$renderid = -1;
934
+ else element.$renderid = -2;
935
935
  element.removeAttribute(name);
936
936
  continue;
937
937
  }
@@ -188,7 +188,7 @@ function main() {
188
188
  appendChild(page, adder);
189
189
  break;
190
190
  case this.children[1]:
191
- var options = [].slice.call(children, 0, children.length);
191
+ var options = Array.apply(null, children);
192
192
  var edit = selectListEdit(options.slice(0));
193
193
  page.with = edit;
194
194
  on("remove")(edit, function () {
@@ -229,6 +229,10 @@ function createState(pgpath) {
229
229
  return state;
230
230
  }
231
231
  function prepare(pgpath, ok) {
232
+ if (pgpath instanceof Array) {
233
+ for (var p of pgpath) prepare(p);
234
+ return;
235
+ }
232
236
  var pgpath = getpgpath(pgpath);
233
237
  if (page_generators[pgpath]) {
234
238
  if (isFunction(ok)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "3.34.3",
3
+ "version": "3.34.6",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {