efront 4.22.18 → 4.22.19

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.
@@ -19,12 +19,9 @@ function _onappend(node, append = createEvent("append"), mount = createEvent("mo
19
19
  }
20
20
  dispatch(node, mount);
21
21
  }
22
+
22
23
  function appendChild(parent, obj, transition) {
23
- if (transition === false) {
24
- var children = [].concat(obj);
25
- } else {
26
- var children = isArrayLike(obj) ? slice.call(obj, 0) : slice.call(arguments, 1);
27
- }
24
+ var children = getArgsChildren(arguments);
28
25
  if (parent.appendChild) {
29
26
  for (var cx = 0, dx = children.length; cx < dx; cx++) {
30
27
  var o = release(children[cx]);
@@ -43,11 +40,7 @@ function appendChild(parent, obj, transition) {
43
40
  function insertBefore(alreadyMounted, obj, transition) {
44
41
  var parent = alreadyMounted && alreadyMounted.parentNode;
45
42
  if (!parent || !parent.insertBefore) return;
46
- if (transition === false) {
47
- var children = [].concat(obj);
48
- } else {
49
- var children = isArray(obj) ? slice.call(obj, 0) : slice.call(arguments, 1);
50
- }
43
+ var children = getArgsChildren(arguments);
51
44
  for (var cx = 0, dx = children.length; cx < dx; cx++) {
52
45
  var o = release(children[cx]);
53
46
  if (!o) continue;
@@ -60,21 +53,20 @@ function insertBefore(alreadyMounted, obj, transition) {
60
53
  }
61
54
  }
62
55
  }
56
+
63
57
  function insertAfter(alreadyMounted, obj, transition) {
64
58
  var parent = alreadyMounted && alreadyMounted.parentNode;
65
59
  if (!parent || !parent.insertBefore) return;
66
- if (transition === false) {
67
- var children = [].concat(obj);
68
- } else {
69
- var children = isArray(obj) ? slice.call(obj, 0) : slice.call(arguments, 1);
70
- }
71
- children = children.reverse();
60
+ var nextSibling = alreadyMounted.nextSibling;
61
+ var children = getArgsChildren(arguments);
62
+ transition = transition !== false;
63
+ if (!nextSibling) return appendChild(parent, children, transition);
72
64
  for (var cx = 0, dx = children.length; cx < dx; cx++) {
73
65
  var o = release(children[cx]);
74
66
  if (!o) continue;
75
67
  if (o.removeTimer) clearTimeout(o.removeTimer);
76
- parent.insertBefore(o, alreadyMounted.nextSibling);
77
- o.with && insertBefore(alreadyMounted.nextSibling, o.with, transition);
68
+ parent.insertBefore(o, nextSibling);
69
+ o.with && insertBefore(nextSibling, o.with, transition);
78
70
  if (isMounted(parent)) _onappend(o);
79
71
  if (hasEnterStyle(o) && transition !== false) {
80
72
  isFunction(appendChild.transition) && appendChild.transition(o);
@@ -0,0 +1,22 @@
1
+ var getArgsChildren = function (args, from = 1) {
2
+ var obj = args[from];
3
+ if (isArray(obj) && !obj.with) return obj;
4
+ var transition = args[from + 1];
5
+ var children;
6
+ if (isArrayLike(obj)) {
7
+ children = Array.apply(null, obj);
8
+ var ith = obj.with;
9
+ while (ith) {
10
+ if (isNode(ith)) children.push(ith), ith = null;
11
+ else if (isArray(ith)) children.push.apply(children, ith), ith = ith.with;
12
+ else ith = null;
13
+ }
14
+ }
15
+ else if (transition === false) {
16
+ children = [].concat(obj);
17
+ }
18
+ else {
19
+ children = Array.prototype.slice.call(args, from);
20
+ }
21
+ return children;
22
+ }
@@ -247,6 +247,9 @@ var setContent = function (value) {
247
247
  if (this.field.type === 'html') this.innerHTML = value;
248
248
  else this.innerText = value;
249
249
  }
250
+ else {
251
+ remove(this.childNodes);
252
+ }
250
253
  };
251
254
  var Binder = render.Binder, Model = render.Model;
252
255
  Object.keys(readonly_types).forEach(k => {
@@ -26,7 +26,26 @@ var popup = function (path) {
26
26
  }
27
27
  throw new Error(i18n`参数异常:${path}`);
28
28
  };
29
+ var onAppendUp = function () {
30
+ var upwith = this.$upwith;
31
+ if (isArray(upwith) && upwith.indexOf(this) < 0) {
32
+ upwith.push(this);
33
+ }
34
+ };
35
+ var onRemoveUp = function () {
36
+ var upwith = this.$upwith;
37
+ if (isArray(upwith)) {
38
+ removeFromList(upwith, this);
39
+ }
40
+ };
41
+ var setUpwith = function (page, upwith) {
42
+ if (!isArray(upwith)) return;
43
+ page.$upwith = upwith;
44
+ on('append')(page, onAppendUp);
45
+ on('remove')(page, onRemoveUp);
46
+ };
29
47
  var popup_path = function (path = "", parameters, target) {
48
+ var upwith_ = upwith;
30
49
  if (!popup.go || !popup.prepare) throw new Error(i18n`当前环境无法使用`);
31
50
  // 3 has mask has view control
32
51
  var element;
@@ -86,6 +105,7 @@ var popup_path = function (path = "", parameters, target) {
86
105
  remove(element && element.$mask);
87
106
  element = popup.create(path, parameters);
88
107
  if (!element) return;
108
+ setUpwith(element, upwith_);
89
109
  load();
90
110
  element.$reload = fullfill;
91
111
  if (target == null && parameters !== false) {
@@ -106,8 +126,9 @@ var popup_path = function (path = "", parameters, target) {
106
126
  }, fullfill
107
127
  };
108
128
  };
109
-
129
+ var upwith = null;
110
130
  var popup_view = function (element, target, style) {
131
+ setUpwith(element, upwith);
111
132
  if (isNode(target)) {
112
133
  if (target.$mask) {
113
134
  popup_with_mask(element, target);
@@ -395,9 +416,19 @@ var popup_fixup = function (element, x, y) {
395
416
  var popup_to_event = function (element, { clientX, clientY }) {
396
417
  popup_fixup(element, clientX, clientY);
397
418
  };
419
+
420
+ popup.upwith = function (collects) {
421
+ return function () {
422
+ upwith = collects;
423
+ var res = popup.apply(this, arguments);
424
+ upwith = null;
425
+ return res;
426
+ }
427
+ };
398
428
  var global = function (element, issingle) {
399
429
  once("remove")(element, cleanup);
400
- rootElements.push(element);
430
+ var upwith = element.$upwith || rootElements;
431
+ if (upwith.indexOf(element) < 0) upwith.push(element);
401
432
  if (isMounted(element)) return;
402
433
  popup.global &&
403
434
  issingle !== false ? popup.global(element, true) : appendChild(document.body, element);
@@ -1,15 +1,6 @@
1
- function remove() {
2
- var [node, transition] = arguments;
1
+ function remove(node, transition) {
3
2
  if (!node) return;
4
- if (isNode(node)) {
5
- if (transition !== false) {
6
- var args = arguments;
7
- } else {
8
- var args = [node];
9
- }
10
- } else {
11
- var args = node;
12
- }
3
+ var args = getArgsChildren(arguments, 0);
13
4
  for (var cx = args.length - 1; cx >= 0; cx--) {
14
5
  node = args[cx];
15
6
  if (!node) continue;
@@ -317,6 +317,7 @@ function prepare(pgpath, ok) {
317
317
  //只能在page上使用
318
318
  _pageback_listener = handler;
319
319
  };
320
+ state.upwith = popup.upwith(_with_elements);
320
321
  state.titlebar = function () {
321
322
  var realTitleBar = titlebar.apply(null, arguments);
322
323
  if (!realTitleBar.parentNode) _with_elements.push(realTitleBar);
@@ -388,8 +389,12 @@ function create(pagepath, args, from, needroles) {
388
389
  var _page = pg.call(state, args, from);
389
390
  if (undefined === args || null === args) args = {};
390
391
  if (_page) {
391
- if (_with_length) _page.with = _with_elements.concat(_page.with || []);
392
- _with_elements.splice(_with_length, _with_elements.length - _with_length);
392
+ var page_with = _with_elements.splice(_with_length, _with_elements.length - _with_length);
393
+ if (_page.with && _page.with !== _with_elements) {
394
+ page_with = page_with.concat(_page.with);
395
+ _with_elements.with = page_with;
396
+ }
397
+ _page.with = _with_elements;
393
398
  if (args.initialStyle) _page.initialStyle = args.initialStyle;
394
399
  if (args.holdupStyle) _page.holdupStyle = args.holdupStyle;
395
400
  if (_page.initialStyle && !_page.holdupStyle) {
@@ -671,7 +676,8 @@ function addGlobal(element, name = null, isBack) {
671
676
  if (isBack) appendChild.insert(body, element);
672
677
  else appendChild(body, element);
673
678
  }
674
- rootElements.push(element);
679
+ var upwith = element.$upwith || rootElements;
680
+ if (upwith.indexOf(element) < 0) upwith.push(element);
675
681
  }
676
682
  if (hasLock) fixurl(), fixLock = false;
677
683
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "4.22.18",
3
+ "version": "4.22.19",
4
4
  "description": "一个开发环境,提供一种自由的前端开发模式,也可作为辅助工具使用。",
5
5
  "main": "public/efront.js",
6
6
  "directories": {