efront 3.19.0 → 3.19.1

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.
@@ -146,5 +146,4 @@ drag.on = function (target, actionTarget = target.dragTarget) {
146
146
  on("drop")(actionTarget || target, setZIndex);
147
147
  onmousedown(target, _mousedrag);
148
148
  ontouchstart(target, _touchdrag);
149
- move.bindPosition(actionTarget || target);
150
149
  };
@@ -152,30 +152,12 @@ var fixPosition = move.fixPosition = function (target) {
152
152
  };
153
153
  move.coordIn = coordIn;
154
154
  move.trimCoord = trimCoord;
155
- var resizingTargets = [];
156
- on('resize')(window, function () {
157
- resizingTargets.forEach(fixPosition);
158
- });
159
- var off;
160
- var resizeTarget = function () {
161
- var target = this;
162
- var index = resizingTargets.indexOf(target);
163
- if (index < 0) index = resizingTargets.push(target);
164
- return index;
155
+ var fixTarget = function () {
156
+ fixPosition(this);
165
157
  };
166
- var removeResize = function () {
167
- removeFromList(resizingTargets, this);
168
- };
169
-
170
158
  move.bindPosition = function (target, position) {
171
- if (position) {
159
+ oncemount(target, function () {
172
160
  setPosition(target, position);
173
- }
174
- var index = resizingTargets.indexOf(target);
175
- if (index >= 0) return;
176
- on("append")(target, resizeTarget);
177
- on("remove")(target, removeResize);
178
- if (isMounted(target)) {
179
- resizeTarget.call(target);
180
- }
161
+ });
162
+ on("resize")(target, fixTarget);
181
163
  }
@@ -3,5 +3,5 @@ function oncemount(target, handle) {
3
3
  handle.call(target);
4
4
  return;
5
5
  }
6
- once("append")(target, handle);
6
+ once("mounted")(target, handle);
7
7
  }
@@ -213,27 +213,40 @@ var createRepeat = function (search, id = 0) {
213
213
  once("append")(this, initialComment.bind(this, renders, "repeat", expression));
214
214
  }
215
215
  };
216
+ var comment = function (elements) {
217
+ for (var cx = elements.length - 2; cx > 1; cx -= 2) {
218
+ var e = elements[cx];
219
+ if (e.previousSibling === this) var c = this;
220
+ else {
221
+ var c = document.createComment('else' + (cx < elements.length - 2 ? "if .." : ''));
222
+ e.parentNode.insertBefore(c, e);
223
+ }
224
+ elements.splice(cx, 0, c);
225
+ remove(e);
226
+ }
227
+ };
228
+ var initIf = function (ifs) {
229
+ for (var s of ifs) {
230
+ comment(s);
231
+ if (s.parent) {
232
+ initialComment.call(s[0], s.renders, "if", s.comment);
233
+ } else {
234
+ once("append")(s[0], initialComment.bind(s[0], s.renders, "if", s.comment));
235
+ }
236
+ }
237
+ };
216
238
  var createIf = function (search, id = 0) {
217
239
  // 懒渲染
218
240
  var getter = createGetter(search).bind(this);
219
241
  var element = this;
220
- var p = element;
221
- if (p.parentNode) {
222
- p = p.parentNode;
223
- for (var cx = 0, dx = if_top.length; cx < dx; cx++) {
224
- if (if_top[cx].parent === p) {
225
- break;
226
- }
227
- }
228
- }
229
- cx++;
230
- if (cx > 0) if_top.splice(cx, if_top.length - cx);
231
242
  var elements = [element, getter];
232
243
  if_top.push(elements);
233
244
  var savedValue;
234
- var renders = [function () {
245
+ elements.parent = this.parentNode;
246
+ elements.comment = search[1];
247
+ elements.renders = [function () {
235
248
  var shouldMount = -1;
236
- for (var cx = 0, dx = elements.length; cx < dx; cx += 2) {
249
+ for (var cx = 0, dx = elements.length; cx < dx; cx += 3) {
237
250
  var getter = elements[cx + 1];
238
251
  if (!getter || getter()) {
239
252
  shouldMount = cx;
@@ -242,10 +255,10 @@ var createIf = function (search, id = 0) {
242
255
  }
243
256
  if (savedValue === shouldMount) return;
244
257
  savedValue = shouldMount;
245
- for (var cx = 0, dx = elements.length; cx < dx; cx += 2) {
258
+ for (var cx = 0, dx = elements.length; cx < dx; cx += 3) {
246
259
  var element = elements[cx];
247
260
  if (cx === shouldMount) {
248
- appendChild.before(this, element);
261
+ appendChild.after(cx > 0 ? elements[cx - 1] : this, element);
249
262
  if (element.renderid < 0) {
250
263
  element.renderid = id;
251
264
  elements[cx] = render(element, this.$scope, this.$parentScopes);
@@ -257,12 +270,6 @@ var createIf = function (search, id = 0) {
257
270
  }
258
271
 
259
272
  }];
260
- if (this.parentNode) {
261
- elements.parent = this.parentNode;
262
- initialComment.call(this, renders, "if", search[1]);
263
- } else {
264
- once("append")(this, initialComment.bind(this, renders, "if", search[1]));
265
- }
266
273
  };
267
274
  var parseIfWithRepeat = function (ifExpression, repeatExpression) {
268
275
  var repeater = parseRepeat(repeatExpression);
@@ -356,15 +363,18 @@ var structures = {
356
363
  createIf.call(this, search);
357
364
  },
358
365
  "else"(search) {
359
- var top = if_top[if_top.length - 1];
360
- if (!top || top.parent !== this.parentNode) {
366
+ for (var cx = if_top.length - 1; cx >= 0; cx--) {
367
+ if (if_top[cx].parent === this.parentNode) break;
368
+ }
369
+ if (cx < 0) {
361
370
  throw new Error("else/elseif前缺少同级if!");
362
371
  }
372
+ initIf(if_top.splice(cx + 1, if_top.length - cx - 1));
373
+ var top = if_top[cx];
363
374
  if (search && search[1]) {
364
375
  var getter = createGetter(search).bind(this);
365
376
  }
366
377
  top.push(this, getter);
367
- remove(this);
368
378
  },
369
379
  repeat(search) {
370
380
  createRepeat.call(this, search);
@@ -853,7 +863,7 @@ function render(element, scope, parentScopes, lazy = true) {
853
863
  renderlock = false;
854
864
  eagermount = false;
855
865
  }
856
- if (if_top_length < if_top.length) if_top.splice(if_top_length, if_top.length - if_top_length);
866
+ if (if_top_length < if_top.length) initIf(if_top.splice(if_top_length, if_top.length - if_top_length));
857
867
  return e;
858
868
  }
859
869
  var digest = lazy(refresh, -{});
@@ -121,11 +121,8 @@ var handle = {
121
121
  }
122
122
  });
123
123
  var rect = dragging.rect;
124
- move.call(rect, isFinite(style.left) ? style.left : rect.offsetLeft, isFinite(style.top) ? style.top : rect.offsetTop);
125
- delete style.left;
126
- delete style.top;
127
- Object.keys(style).forEach(k => style[k] = fromOffset(style[k]));
128
124
  css(dragging.rect, style);
125
+ move.call(rect, isFinite(style.left) ? style.left : rect.offsetLeft, isFinite(style.top) ? style.top : rect.offsetTop);
129
126
  dispatch(dragging.rect, 'resize');
130
127
  resizingList.forEach(a => {
131
128
  if (getTargetIn(dragging.rect, a)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "3.19.0",
3
+ "version": "3.19.1",
4
4
  "description": "一个开发工具,开放源代码,自带组件库和编译环境,可以用来开发web组件,web应用或nodejs模块,或做为已有代码的加密工具,也可以做为静态页面服务器或跨域中转服务器使用",
5
5
  "main": "public/efront.js",
6
6
  "directories": {