efront 3.11.1 → 3.12.0

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.
@@ -91,15 +91,17 @@ var constructors = {
91
91
  }
92
92
  else if (t === 'a') {
93
93
  var { field, data } = _;
94
- var pad = selectList(field.options, field.multi, true);
95
- var e = document.createElement('select');
96
94
  var opt = null;
97
- for (var o of field.options) {
95
+ for (var cx = 0, options = field.options, dx = options.length; cx < dx; cx++) {
96
+ var o = options[cx];
98
97
  if (o.key === data[field.key]) {
99
98
  opt = o;
99
+ o.selected = true;
100
100
  break;
101
101
  }
102
102
  }
103
+ var pad = selectList(field.options, field.multi, true);
104
+ var e = document.createElement('select');
103
105
  e.innerHTML = `<option selected value="${opt ? opt.key : ''}">${opt ? opt.name : '请选择'}</option>`;
104
106
  e.value = opt ? opt.key : '';
105
107
  elem = select(e, pad);
@@ -529,14 +529,14 @@ var binders = {
529
529
  };
530
530
  var createEmiter = function (on) {
531
531
  return function (key, search) {
532
- if (this.$src) {
533
- var parsedSrc = this.$src;
532
+ var parsedSrc = this.$src;
533
+ var getter0 = createGetter(search, false), getter1;
534
+ if (parsedSrc) {
534
535
  var scopes = this.$parentScopes;
535
536
  search = search.slice();
536
537
  search[0] += `with(this.$parentScopes[${scopes.length}])`;
537
- this.$parentScopes = scopes.concat(this.$scope);
538
+ getter1 = createGetter(search, false);
538
539
  }
539
- var getter = createGetter(search, false);
540
540
  on(key)(this, function (e) {
541
541
  if (parsedSrc) {
542
542
  var target = e.currentTarget || e.target;
@@ -556,12 +556,14 @@ var createEmiter = function (on) {
556
556
  var res;
557
557
  if (scope) {
558
558
  var temp = this.$scope;
559
+ this.$parentScopes.push(temp);
559
560
  this.$scope = scope;
560
- res = getter.call(this, e);
561
+ res = getter1.call(this, e);
562
+ this.$parentScopes.pop();
561
563
  this.$scope = temp;
562
564
  }
563
565
  else {
564
- res = getter.call(this, e);
566
+ res = getter0.call(this, e);
565
567
  }
566
568
  if (res && isFunction(res.then)) res.then(digest, digest);
567
569
  digest();
@@ -581,7 +583,7 @@ function getFromScopes(key, scope, parentScopes) {
581
583
  }
582
584
  if (parentScopes) for (var cx = parentScopes.length - 1; cx >= 0; cx--) {
583
585
  var o = parentScopes[cx];
584
- if (key in o) {
586
+ if (o && key in o) {
585
587
  return o[key];
586
588
  }
587
589
  }
@@ -614,13 +616,13 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
614
616
  return element;
615
617
  }
616
618
  var isFirstRender = !element.renderid;
617
- element.renderid = 1;
618
- var parentNode = element.parentNode;
619
- if (parentNode) {
620
- if (parentNode.renderid > 1 || parentNode.isMounted) element.renderid = 2;
621
- }
622
619
 
623
620
  if (isFirstRender) {
621
+ element.renderid = 1;
622
+ var parentNode = element.parentNode;
623
+ if (parentNode) {
624
+ if (parentNode.renderid > 1 || parentNode.isMounted) element.renderid = 2;
625
+ }
624
626
  element.renders = element.renders ? [].concat(element.renders) : [];
625
627
  var { ons, copys, attrs, props, binds, context: withContext } = element.$struct;
626
628
  delete element.$struct;
@@ -1,12 +1,17 @@
1
1
  var singleClick = function () {
2
2
  var node = this.parentNode;
3
3
  if (node.activeNode === this) return;
4
- if (node.activeNode) node.activeNode.removeAttribute("selected");
4
+ if (node.activeNode) {
5
+ if (node.activeNode.origin) node.activeNode.origin.selected = false;
6
+ node.activeNode.removeAttribute("selected");
7
+ }
5
8
  this.setAttribute("selected", "");
9
+
6
10
  node.activeNode = this;
7
11
  if (node.value === this.value) return;
8
12
  node.value = this.value;
9
13
  node.name = this.name;
14
+ if (this.origin) this.origin.selected = true;
10
15
  dispatch(node, "change");
11
16
  };
12
17
  var multipleClick = function () {
@@ -20,13 +25,13 @@ var multipleClick = function () {
20
25
  values.splice(index, 1);
21
26
  this.removeAttribute("selected");
22
27
  }
28
+ if (this.origin) this.origin.selected = true;
23
29
  dispatch(node, "change");
24
30
  };
25
31
 
26
32
  function main(children, multiple, addable) {
27
33
  var page = div();
28
34
  page.value = multiple ? [] : "";
29
- var firstValue = false;
30
35
  var clicker = multiple ? multipleClick : singleClick;
31
36
  var itemMap = Object.create(null);
32
37
  function createItem(option) {
@@ -36,6 +41,7 @@ function main(children, multiple, addable) {
36
41
  item.setAttribute("item", '');
37
42
  item.innerHTML = option.innerHTML || option.name;
38
43
  item.name = option.name || option.innerHTML;
44
+ item.origin = option;
39
45
  var icon = option.getAttribute ? option.getAttribute("icon") : option.icon;
40
46
  if (icon) {
41
47
  if (!hasIcon) {
@@ -50,10 +56,10 @@ function main(children, multiple, addable) {
50
56
  if (multiple) {
51
57
  item.setAttribute("selected", "");
52
58
  page.value.push(option.value);
53
- } else if (!firstValue) {
59
+ }
60
+ else {
54
61
  item.setAttribute("selected", "");
55
62
  page.activeNode = item;
56
- firstValue = true;
57
63
  page.value = option.value
58
64
  }
59
65
  }
@@ -15,7 +15,7 @@
15
15
  padding: 0 16px;
16
16
 
17
17
  &[selected] {
18
- color: #26f;
18
+ color: #29e;
19
19
  }
20
20
 
21
21
  &:hover {
@@ -132,16 +132,18 @@ function tree() {
132
132
  }
133
133
  var tabs = new Array(com.tab + 1).join("<t></t>");
134
134
  if (isFunction(generator)) {
135
- var elem = generator(index, com);
135
+ var elem = generator(index, com instanceof Item ? com.value : com);
136
136
  if (!elem) return;
137
- span = document.createElement('div');
137
+ span = document.createElement('span');
138
138
  span.innerHTML = tabs;
139
- span.appendChild(elem);
139
+ elem.insertBefore(span, elem.firstChild);
140
+ span = elem;
140
141
  } else {
141
- span = div();
142
+ span = document.createElement("node");
142
143
  html(span, `${tabs}<c>${com.name}</c>${com.test ? "<i>_test</i>" : ""}<a class=count>${com.count}</a>`);
143
144
  }
144
145
  var _div = button(span);
146
+ _div.setAttribute("node", '');
145
147
  _div.index = index;
146
148
 
147
149
  if (!com.saved) {
@@ -222,7 +224,7 @@ function tree() {
222
224
  _div.refresh();
223
225
  onclick(_div, function () {
224
226
  var isClosed = com.isClosed();
225
- if (!active(banner, com.value, com)) {
227
+ if (!active(banner, com.value, com, _div)) {
226
228
  return;
227
229
  }
228
230
  if (isClosed === com.isClosed() && com.length) {
@@ -3,13 +3,26 @@
3
3
  background: #222d32;
4
4
  color: #fff;
5
5
 
6
- >div {
6
+ >[node] {
7
7
  display: block;
8
8
  text-align: left;
9
9
  height: auto;
10
10
  background-color: inherit;
11
11
  color: inherit;
12
12
  padding-right: 10px;
13
+ padding-top: 4px;
14
+ padding-bottom: 4px;
15
+ box-shadow: none;
16
+
17
+ &.line,
18
+ &[line] {
19
+ box-shadow: none;
20
+ line-height: 0;
21
+
22
+ >.track {
23
+ display: none;
24
+ }
25
+ }
13
26
  }
14
27
  }
15
28
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "3.11.1",
3
+ "version": "3.12.0",
4
4
  "description": "一个开发工具,开放源代码,自带组件库和编译环境,可以用来开发web组件,web应用或nodejs模块,或做为已有代码的加密工具,也可以做为静态页面服务器或跨域中转服务器使用",
5
5
  "main": "public/efront.js",
6
6
  "directories": {