efront 4.22.13 → 4.22.16
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.
- package/#/345/233/275/351/231/205/345/214/226.yml +3 -0
- package/apps/pivot/cert/main.xht +1 -1
- package/apps/pivot/db/config.xht +4 -2
- package/apps/pivot/db/list.xht +1 -0
- package/coms/basic/JSAM.js +197 -261
- package/coms/basic/JSAM_test.js +27 -0
- package/coms/basic/data.js +17 -4
- package/coms/basic/isArrayLike.js +3 -2
- package/coms/compile//347/264/240/351/246/250.js +19 -8
- package/coms/compile//347/264/240/351/246/250_test.js +2 -2
- package/coms/reptile/colored_console.js +1 -0
- package/coms/zimoli/alert.js +17 -5
- package/coms/zimoli/appendChild.js +1 -0
- package/coms/zimoli/list.js +25 -11
- package/coms/zimoli/popup.js +17 -11
- package/coms/zimoli/render.js +122 -54
- package/coms/zimoli/transition.js +0 -2
- package/coms/zimoli/tree.js +16 -25
- package/coms/zimoli/zIndex.js +1 -0
- package/docs/main.xht +14 -14
- package/package.json +1 -1
- package/public/efront.js +1 -1
|
@@ -441,18 +441,29 @@ var fixBase = function (b, a) {
|
|
|
441
441
|
return splitParams(a).map(a => {
|
|
442
442
|
if (presets.test(a)) a = `@{${a}}`;
|
|
443
443
|
var replaced = false;
|
|
444
|
+
var rootindex = 0;
|
|
445
|
+
a.replace(/\:root/g, function (match, index) {
|
|
446
|
+
rootindex = match.length + index;
|
|
447
|
+
return '';
|
|
448
|
+
})
|
|
449
|
+
if (rootindex > 0) a = a.slice(rootindex);
|
|
444
450
|
return splitParams(b).map(b => {
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
451
|
+
var b1 = b.replace(/^\:root\s*/g, '');
|
|
452
|
+
var rindex = rootindex;
|
|
453
|
+
if (b1.length !== b.length) rindex = true;;
|
|
454
|
+
b = b1;
|
|
455
|
+
b = b.replace(/^(&|\:scope)\s*/g, "");
|
|
456
|
+
var a1 = a.replace(/&|\:scope/g, function () {
|
|
448
457
|
replaced = true;
|
|
449
|
-
return b;
|
|
458
|
+
if (!rindex) return b;
|
|
459
|
+
return '';
|
|
450
460
|
});
|
|
461
|
+
if (!b && !replaced) return a1;
|
|
451
462
|
if (!replaced) {
|
|
452
463
|
if (/^[\>~\+]/.test(a) || /[\>~\+]$/.test(b)) {
|
|
453
|
-
a1 = b +
|
|
464
|
+
a1 = b + a1;
|
|
454
465
|
}
|
|
455
|
-
else a1 = b + " " + a;
|
|
466
|
+
else if (!rindex) a1 = b + " " + a;
|
|
456
467
|
}
|
|
457
468
|
return a1;
|
|
458
469
|
}).join(",");
|
|
@@ -494,7 +505,7 @@ var Method = function () {
|
|
|
494
505
|
vlist.pop();
|
|
495
506
|
return body;
|
|
496
507
|
}
|
|
497
|
-
var vlist = [], mlist = [macros], clist = [], base =
|
|
508
|
+
var vlist = [], mlist = [macros], clist = [], base = "";
|
|
498
509
|
var killneg = function (v, n) {
|
|
499
510
|
if (n === "-") {
|
|
500
511
|
if (/^\-/.test(v)) {
|
|
@@ -529,7 +540,7 @@ var initvars = function (vars) {
|
|
|
529
540
|
};
|
|
530
541
|
var evalthis = function (p) {
|
|
531
542
|
var temp = base;
|
|
532
|
-
base = p.base;
|
|
543
|
+
base = p.base || "&";
|
|
533
544
|
var res = eval2(p.used);
|
|
534
545
|
base = temp;
|
|
535
546
|
return res;
|
|
@@ -62,10 +62,10 @@ test(`.type(@type,@media) {.@{type} {&:before{content:"@{media}";}}}.type(videoi
|
|
|
62
62
|
assert(素馨(`:not(a):not(b){c:d}`, 'abc'), `abc :not(a):not(b){c:d;}`);
|
|
63
63
|
assert(素馨(`&:not(a):not(b){c:d}`, 'abc'), `abc:not(a):not(b){c:d;}`);
|
|
64
64
|
assert(素馨(`:scope{&:not(a):not(b){c:d}}`, 'abc'), `abc:not(a):not(b){c:d;}`);
|
|
65
|
-
assert(素馨(`:root{&:not(a):not(b){c:d}}`, '
|
|
65
|
+
assert(素馨(`:root{&:not(a):not(b){c:d}}`, 'abc1'), `:not(a):not(b){c:d;}`);
|
|
66
66
|
assert(素馨(`&{&:not(a):not(b){c:d}}`, 'abc'), `abc:not(a):not(b){c:d;}`);
|
|
67
67
|
assert(素馨(`:root>a{&:not(a):not(b){c:d}}`, '.abc-'), `.abc->a:not(a):not(b){c:d;}`);
|
|
68
|
-
assert(素馨(`a>:root{&:not(a):not(b){c:d}}`, '.abc-'),
|
|
68
|
+
assert(素馨(`a>:root{&:not(a):not(b){c:d}}`, '.abc-'), `:not(a):not(b){c:d;}`);
|
|
69
69
|
|
|
70
70
|
assert(素馨(`.a (){ &:after{abc:1}} .b{.a();}`, '.abc-'), `.abc- .b:after{abc:1;}`);
|
|
71
71
|
assert(素馨(`@a:1px;@margin-x:@a+10px; a{m:-@margin-x}`), `a{m:-11px;}`);
|
package/coms/zimoli/alert.js
CHANGED
|
@@ -16,20 +16,27 @@ css(container, 'top:0;height:0;left:0;right:0;transition:all 0.2s ease-out;posit
|
|
|
16
16
|
var _text = function (elem, bgcolor, parameters) {
|
|
17
17
|
var box = elem || document.createElement('div');
|
|
18
18
|
css(box, `background-color:${bgcolor};color:${color.pair(bgcolor, 1)};`);
|
|
19
|
-
box.
|
|
19
|
+
remove(box.childNodes);
|
|
20
|
+
appendChild(box, parameters);
|
|
20
21
|
box.initialStyle = `margin-top:-${fromPixel(singleHeight)};`;
|
|
21
22
|
return box;
|
|
22
23
|
};
|
|
23
24
|
function alert() {
|
|
24
25
|
var clr = String(isString(this) && this || styles.default), text, autoclose = true, onclose;
|
|
26
|
+
var fade = [];
|
|
25
27
|
var setArg = function (args) {
|
|
26
28
|
text = '';
|
|
29
|
+
fade = [];
|
|
27
30
|
autoclose = true;
|
|
28
31
|
for (var arg of args) switch (typeof arg) {
|
|
29
|
-
case "string":
|
|
30
32
|
case "object":
|
|
33
|
+
if (isNode(arg)) {
|
|
34
|
+
fade.push(arg);
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
case "string":
|
|
31
38
|
arg = String(arg);
|
|
32
|
-
if (!text) {
|
|
39
|
+
if (!text && !fade.length) {
|
|
33
40
|
text = arg;
|
|
34
41
|
} else if (color.isColor(text)) {
|
|
35
42
|
clr = text;
|
|
@@ -42,6 +49,9 @@ function alert() {
|
|
|
42
49
|
} else if (color.isColor(arg)) {
|
|
43
50
|
clr = arg;
|
|
44
51
|
}
|
|
52
|
+
else {
|
|
53
|
+
fade.push(arg);
|
|
54
|
+
}
|
|
45
55
|
break;
|
|
46
56
|
case "boolean":
|
|
47
57
|
case "number":
|
|
@@ -66,10 +76,12 @@ function alert() {
|
|
|
66
76
|
}
|
|
67
77
|
};
|
|
68
78
|
var setContent = function (elem) {
|
|
79
|
+
var t = [text];
|
|
80
|
+
if (fade.length) t.push(...fade);
|
|
69
81
|
if (color.isColor(clr)) {
|
|
70
|
-
elem = _text(elem, clr,
|
|
82
|
+
elem = _text(elem, clr, t);
|
|
71
83
|
} else {
|
|
72
|
-
elem = _text(elem, styles.log,
|
|
84
|
+
elem = _text(elem, styles.log, t);
|
|
73
85
|
}
|
|
74
86
|
if (!isMounted(container)) popup(container);
|
|
75
87
|
if (!isMounted(elem)) appendChild(container, elem);
|
|
@@ -110,6 +110,7 @@ var wrapTargetMethod = function (target, methodName) {
|
|
|
110
110
|
};
|
|
111
111
|
newMethod.wrapped = true;
|
|
112
112
|
};
|
|
113
|
+
appendChild.dispatch = _onappend;
|
|
113
114
|
appendChild.wrapTarget = function (target) {
|
|
114
115
|
wrapTargetMethod(target, 'insertBefore');
|
|
115
116
|
wrapTargetMethod(target, 'appendChild');
|
package/coms/zimoli/list.js
CHANGED
|
@@ -51,7 +51,7 @@ function ylist(container, generator, $Y) {
|
|
|
51
51
|
}
|
|
52
52
|
return null;
|
|
53
53
|
};
|
|
54
|
-
var isSticky = child =>
|
|
54
|
+
var isSticky = child => isElement(child) && /^(sticky|fixed|absolute)$/.test(getComputedStyle(child).position);
|
|
55
55
|
var getFirstVisibleElement = function (deltaY) {
|
|
56
56
|
var children = list.childNodes;
|
|
57
57
|
var { scrollTop } = list;
|
|
@@ -60,8 +60,9 @@ function ylist(container, generator, $Y) {
|
|
|
60
60
|
if (deltaY) scrollTop += deltaY;
|
|
61
61
|
for (var cx = 0, dx = children.length; cx < dx; cx++) {
|
|
62
62
|
var child = children[cx];
|
|
63
|
-
if (!isFinite(child.index) || child.index === null
|
|
63
|
+
if (!isFinite(child.index) || child.index === null) continue;
|
|
64
64
|
var c = getNodeTarget(child);
|
|
65
|
+
if (isSticky(c)) continue;
|
|
65
66
|
if (c.offsetTop + c.offsetHeight >= scrollTop + 1) return deltaY === 0 ? child : c;
|
|
66
67
|
}
|
|
67
68
|
return null;
|
|
@@ -108,8 +109,9 @@ function ylist(container, generator, $Y) {
|
|
|
108
109
|
var children = list.children;
|
|
109
110
|
for (var cx = children.length - 1; cx >= 0; cx--) {
|
|
110
111
|
var child = children[cx];
|
|
111
|
-
if (!isFinite(child.index)
|
|
112
|
+
if (!isFinite(child.index)) continue;
|
|
112
113
|
var c = getNodeTarget(child);
|
|
114
|
+
if (isSticky(c)) continue;
|
|
113
115
|
if (c.offsetTop + 1 <= scrollTop + list.clientHeight - paddingBottom) {
|
|
114
116
|
return deltaY === 0 ? child : c;
|
|
115
117
|
}
|
|
@@ -147,7 +149,7 @@ function ylist(container, generator, $Y) {
|
|
|
147
149
|
saved_itemIndex = itemIndex;
|
|
148
150
|
return;
|
|
149
151
|
}
|
|
150
|
-
var cache_height = list.offsetHeight;
|
|
152
|
+
var cache_height = Math.min(list.offsetHeight, screen.height >> 1);
|
|
151
153
|
var index = itemIndex | 0;
|
|
152
154
|
if (itemIndex < 0) index--;
|
|
153
155
|
var ratio = itemIndex - index || 0;
|
|
@@ -160,7 +162,10 @@ function ylist(container, generator, $Y) {
|
|
|
160
162
|
if (last_item) last_item = getNodeTarget(last_item);
|
|
161
163
|
var count = 0, delta = 1, bottom_item, offsett = offset, offsetb = offset, top_item;
|
|
162
164
|
var indexed_item;
|
|
163
|
-
|
|
165
|
+
var limitHeight = screen.height;
|
|
166
|
+
while (
|
|
167
|
+
offsetBottom - ratioTop <= limitHeight + cache_height
|
|
168
|
+
|| delta < 0 && indexed_item && top_item && indexed_item.offsetTop - top_item.offsetTop < cache_height) {
|
|
164
169
|
var item = childrenMap[offset];
|
|
165
170
|
if (!item) {
|
|
166
171
|
item = createItem(offset);
|
|
@@ -198,7 +203,15 @@ function ylist(container, generator, $Y) {
|
|
|
198
203
|
}
|
|
199
204
|
offsetBottom = bottom_item.offsetTop + bottom_item.offsetHeight;
|
|
200
205
|
ratioTop = top_item.offsetTop + top_item.offsetHeight * ratio;
|
|
201
|
-
if (count++ > 600) throw
|
|
206
|
+
if (count++ > 600) throw console.log(
|
|
207
|
+
`头部下标`, index,
|
|
208
|
+
`当前下标`, offset,
|
|
209
|
+
`缓冲尺寸`, cache_height,
|
|
210
|
+
'限制尺寸', limitHeight,
|
|
211
|
+
'框架尺寸', list.offsetHeight,
|
|
212
|
+
'当前绘制到', ratioTop,
|
|
213
|
+
`当前元素到顶部元素占用`, offsetBottom - ratioTop
|
|
214
|
+
), new Error(i18n`多于600个元素需要绘制!`);
|
|
202
215
|
}
|
|
203
216
|
for (var k in childrenMap) {
|
|
204
217
|
remove(childrenMap[k]);
|
|
@@ -249,7 +262,8 @@ function ylist(container, generator, $Y) {
|
|
|
249
262
|
if (elem.with) for (var w of elem.with) list.insertBefore(w, flag);
|
|
250
263
|
};
|
|
251
264
|
var patchBottom = function (deltaY = 0) {
|
|
252
|
-
var cache_height = list.offsetHeight;
|
|
265
|
+
var cache_height = Math.min(list.offsetHeight, screen.height >> 1);
|
|
266
|
+
var limitHeight = screen.height + cache_height;
|
|
253
267
|
var childrenMap = getChildrenMap();
|
|
254
268
|
var last_element = getLastElement(1);
|
|
255
269
|
if (!last_element || !last_element.offsetHeight) return;
|
|
@@ -258,7 +272,7 @@ function ylist(container, generator, $Y) {
|
|
|
258
272
|
var offsetBottom = getOffsetHeight(last_element) + last_element.offsetTop;
|
|
259
273
|
var offset = last_element.index || 0;
|
|
260
274
|
//追加元素到底部
|
|
261
|
-
while (offsetBottom <= scrollTop +
|
|
275
|
+
while (offsetBottom <= scrollTop + limitHeight) {
|
|
262
276
|
offset++;
|
|
263
277
|
var item = childrenMap[offset];
|
|
264
278
|
if (!item) {
|
|
@@ -282,7 +296,7 @@ function ylist(container, generator, $Y) {
|
|
|
282
296
|
var collection = [];
|
|
283
297
|
for (var k in childrenMap) {
|
|
284
298
|
let item = childrenMap[k];
|
|
285
|
-
if (getNodeTarget(item).offsetTop + getOffsetHeight(item) +
|
|
299
|
+
if (getNodeTarget(item).offsetTop + getOffsetHeight(item) + limitHeight < scrollTop) {
|
|
286
300
|
collection.push(item);
|
|
287
301
|
}
|
|
288
302
|
}
|
|
@@ -310,7 +324,7 @@ function ylist(container, generator, $Y) {
|
|
|
310
324
|
return scrollTop - list.scrollTop;
|
|
311
325
|
};
|
|
312
326
|
var patchTop = function (deltaY = 0) {
|
|
313
|
-
var cache_height = list.offsetHeight;
|
|
327
|
+
var cache_height = Math.min(list.offsetHeight, screen.height >> 1);
|
|
314
328
|
|
|
315
329
|
var childrenMap = getChildrenMap();
|
|
316
330
|
var first_element, flag_element = first_element = getFirstElement(1);
|
|
@@ -320,7 +334,7 @@ function ylist(container, generator, $Y) {
|
|
|
320
334
|
var { scrollTop } = list;
|
|
321
335
|
scrollTop += deltaY;
|
|
322
336
|
//追加元素到顶部
|
|
323
|
-
var targetHeight = cache_height + first_element.offsetTop;
|
|
337
|
+
var targetHeight = screen.height + cache_height + first_element.offsetTop;
|
|
324
338
|
var { paddingCount, paddingMax } = list;
|
|
325
339
|
if (!(paddingCount > 0 && paddingMax > 0 && paddingCount < paddingMax) || !(scrollTop < targetHeight)) {
|
|
326
340
|
paddingCount = 0;
|
package/coms/zimoli/popup.js
CHANGED
|
@@ -68,13 +68,16 @@ var popup_path = function (path = "", parameters, target) {
|
|
|
68
68
|
}
|
|
69
69
|
else if (target instanceof Event) {
|
|
70
70
|
popup_to_event(element, target);
|
|
71
|
-
}
|
|
71
|
+
}
|
|
72
|
+
else if (target instanceof Array) {
|
|
72
73
|
popup_to_point(element, target);
|
|
73
|
-
}
|
|
74
|
+
}
|
|
75
|
+
else if (target < 0 || target === true) {
|
|
74
76
|
popup_with_mask(element);
|
|
75
|
-
}
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
76
79
|
if (parameters !== false && target !== false) setInitialStyle(element);
|
|
77
|
-
popup_as_single(element);
|
|
80
|
+
popup_as_single(element, target);
|
|
78
81
|
}
|
|
79
82
|
};
|
|
80
83
|
}
|
|
@@ -85,7 +88,7 @@ var popup_path = function (path = "", parameters, target) {
|
|
|
85
88
|
if (!element) return;
|
|
86
89
|
load();
|
|
87
90
|
element.$reload = fullfill;
|
|
88
|
-
if (
|
|
91
|
+
if (target == null && parameters !== false) {
|
|
89
92
|
element.style.opacity = 0;
|
|
90
93
|
oncemount(element, function () {
|
|
91
94
|
move.bindPosition(element, [.5, .5]);
|
|
@@ -114,14 +117,17 @@ var popup_view = function (element, target, style) {
|
|
|
114
117
|
}
|
|
115
118
|
if (target instanceof Event) {
|
|
116
119
|
popup_to_event(element, target);
|
|
117
|
-
}
|
|
120
|
+
}
|
|
121
|
+
else if (target instanceof Array) {
|
|
118
122
|
if (isNode(style) && style.$mask) addMask(element, style);
|
|
119
123
|
else if (typeof style === 'boolean') addMask(element);
|
|
120
124
|
popup_to_point(element, target);
|
|
121
|
-
}
|
|
125
|
+
}
|
|
126
|
+
else if (target === true || target < 0) {
|
|
122
127
|
popup_with_mask(element);
|
|
123
|
-
}
|
|
124
|
-
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
popup_as_single(element, target);
|
|
125
131
|
}
|
|
126
132
|
return element;
|
|
127
133
|
};
|
|
@@ -337,8 +343,8 @@ var _as_yextra = function (global, innerWidth, innerHeight, element, target, poi
|
|
|
337
343
|
global(element, false);
|
|
338
344
|
};
|
|
339
345
|
var _as_xextra = arriswise(_as_yextra, arguments);
|
|
340
|
-
var popup_as_single = function (element) {
|
|
341
|
-
if (!isMounted(element)) css(element, `z-index:${zIndex()};`);
|
|
346
|
+
var popup_as_single = function (element, z) {
|
|
347
|
+
if (!isMounted(element)) css(element, `z-index:${Number.isFinite(z) ? z : zIndex()};`);
|
|
342
348
|
global(element, false);
|
|
343
349
|
};
|
|
344
350
|
var popup_to_point = function (element, [x, y]) {
|
package/coms/zimoli/render.js
CHANGED
|
@@ -60,11 +60,10 @@ var renderidClosed = 0;
|
|
|
60
60
|
var addRenderElement = function () {
|
|
61
61
|
var element = this;
|
|
62
62
|
if (!isNode(element)) return;
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
buildFirst(element);
|
|
64
|
+
if (element.$renderid > 10) {
|
|
65
65
|
renderElements[element.$renderid] = element;
|
|
66
66
|
}
|
|
67
|
-
buildFirst(element);
|
|
68
67
|
};
|
|
69
68
|
var removeRenderElement = function () {
|
|
70
69
|
var element = this;
|
|
@@ -144,14 +143,39 @@ var getScopeList = function (element) {
|
|
|
144
143
|
if (element.$scope) scopes.push(element.$scope);
|
|
145
144
|
return scopes;
|
|
146
145
|
};
|
|
146
|
+
var toNull = () => null;
|
|
147
|
+
var toUndefined = () => { };
|
|
148
|
+
var toResult = function (c) {
|
|
149
|
+
if (typeof c === 'function') return c();
|
|
150
|
+
return c;
|
|
151
|
+
};
|
|
152
|
+
var toObject = function (object) {
|
|
153
|
+
if (isArray(object)) return function (object) {
|
|
154
|
+
return object.map(toResult);
|
|
155
|
+
}
|
|
156
|
+
return function () {
|
|
157
|
+
var result = {};
|
|
158
|
+
for (var k in object) result[k] = toResult(object[k]);
|
|
159
|
+
return result;
|
|
160
|
+
}
|
|
161
|
+
};
|
|
147
162
|
var createGetter = function (target, search, isprop = true) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
163
|
+
switch (typeof search) {
|
|
164
|
+
case "function":
|
|
165
|
+
return search;
|
|
166
|
+
case "string":
|
|
167
|
+
if (!search) return toUndefined;
|
|
168
|
+
if (/^\{/.test(search)) search = `(${search})`;
|
|
169
|
+
search = renderExpress(search);
|
|
170
|
+
if (isprop) var getter = $$eval.bind(target, search, getScopeList(target));
|
|
171
|
+
else if (variableOnlyReg.test(search)) getter = $$eval.bind(target, search + "(event)");
|
|
172
|
+
else getter = $$eval.bind(target, search);
|
|
173
|
+
return getter;
|
|
174
|
+
case "object":
|
|
175
|
+
if (!isprop) throw new Error('绑定错误');
|
|
176
|
+
return toObject(search);
|
|
177
|
+
}
|
|
178
|
+
return toUndefined;
|
|
155
179
|
};
|
|
156
180
|
var createComment = function (renders, type, expression) {
|
|
157
181
|
var comment = document.createComment(`${type} ${expression}`);
|
|
@@ -337,11 +361,6 @@ var createRepeat = function (search, id = 0) {
|
|
|
337
361
|
initialComment(comment);
|
|
338
362
|
return comment;
|
|
339
363
|
};
|
|
340
|
-
var initIfs = function (ifs) {
|
|
341
|
-
for (var s of ifs) {
|
|
342
|
-
initialComment(s[0]);
|
|
343
|
-
}
|
|
344
|
-
};
|
|
345
364
|
|
|
346
365
|
var ifget = function () {
|
|
347
366
|
var elements = this.$elements;
|
|
@@ -384,6 +403,7 @@ var createIf = function (search, id = 0) {
|
|
|
384
403
|
var comment = elements[0] = createComment.call(element, [new Binder2(ifget, ifset)], 'if', search);
|
|
385
404
|
comment.$id = id;
|
|
386
405
|
comment.$elements = elements;
|
|
406
|
+
initialComment(comment);
|
|
387
407
|
return comment;
|
|
388
408
|
};
|
|
389
409
|
var parseIfWithRepeat = function (ifExpression, repeatExpression) {
|
|
@@ -495,7 +515,7 @@ var structures = {
|
|
|
495
515
|
if (cx < 0) {
|
|
496
516
|
throw new Error(i18n`else/elseif前缺少同级if!`);
|
|
497
517
|
}
|
|
498
|
-
if (cx + 1 < if_top.length)
|
|
518
|
+
if (cx + 1 < if_top.length) if_top.splice(cx + 1, if_top.length - cx - 1);
|
|
499
519
|
var top = if_top[cx];
|
|
500
520
|
if (search) var getter = createGetter(this, search);
|
|
501
521
|
var comment = createComment.call(this, undefined, search ? 'elseif' : 'else', search);
|
|
@@ -838,7 +858,7 @@ function renderProp(elem, props) {
|
|
|
838
858
|
}
|
|
839
859
|
}
|
|
840
860
|
|
|
841
|
-
function renderBinds(element, binds
|
|
861
|
+
function renderBinds(element, binds) {
|
|
842
862
|
var bind = binders._;
|
|
843
863
|
for (var k in binds) {
|
|
844
864
|
if (directives.hasOwnProperty(k)) continue;
|
|
@@ -846,8 +866,7 @@ function renderBinds(element, binds, init) {
|
|
|
846
866
|
h.call(element);
|
|
847
867
|
}
|
|
848
868
|
}
|
|
849
|
-
|
|
850
|
-
function renderRest(element, struct, replacer = element) {
|
|
869
|
+
function renderDynamics(element, replacer, binds, attrs) {
|
|
851
870
|
var renders = element.$renders;
|
|
852
871
|
if (element.renders) {
|
|
853
872
|
if (!renders) renders = [];
|
|
@@ -855,7 +874,6 @@ function renderRest(element, struct, replacer = element) {
|
|
|
855
874
|
delete element.renders;
|
|
856
875
|
}
|
|
857
876
|
element.$renders = [];
|
|
858
|
-
var { attrs, binds } = struct;
|
|
859
877
|
var bindWatch = !!element.$needchanges;
|
|
860
878
|
for (var k in binds) {
|
|
861
879
|
if (k in directives) {
|
|
@@ -870,13 +888,23 @@ function renderRest(element, struct, replacer = element) {
|
|
|
870
888
|
}
|
|
871
889
|
}
|
|
872
890
|
}
|
|
873
|
-
for (var k in
|
|
891
|
+
for (var k in attrs) {
|
|
874
892
|
binders[""].call(element, k, attrs[k]);
|
|
875
893
|
}
|
|
876
894
|
if (renders && renders.length) element.$renders.push.apply(element.$renders, renders);
|
|
877
895
|
if (binds.src) directives.src.call(element, binds.src);
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
function renderEmits(replacer, emits, on) {
|
|
899
|
+
for (var k in emits) on.call(this, replacer, k, emits[k]);
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
function renderRest(element, struct, replacer = element) {
|
|
903
|
+
var { attrs, binds, emits, waits } = struct;
|
|
904
|
+
renderDynamics(element, replacer, binds, attrs);
|
|
878
905
|
if (!isElement(replacer)) replacer = element;
|
|
879
|
-
|
|
906
|
+
renderEmits.call(element, replacer, emits, emiters.on);
|
|
907
|
+
renderEmits.call(element, replacer, waits, emiters.once);
|
|
880
908
|
}
|
|
881
909
|
function renderArray(children, scope, parentScopes, once) {
|
|
882
910
|
if (!children) return;
|
|
@@ -886,7 +914,7 @@ function renderArray(children, scope, parentScopes, once) {
|
|
|
886
914
|
children[cx] = renderElement(children[cx], scope, parentScopes, once);
|
|
887
915
|
}
|
|
888
916
|
if (if_top_length < if_top.length) {
|
|
889
|
-
|
|
917
|
+
if_top.splice(if_top_length, if_top.length - if_top_length);
|
|
890
918
|
}
|
|
891
919
|
};
|
|
892
920
|
return children;
|
|
@@ -915,7 +943,6 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
|
|
|
915
943
|
throw new Error(i18n`父作用域链的长度必须相等着`);
|
|
916
944
|
}
|
|
917
945
|
}
|
|
918
|
-
element.$parentScopes = parentScopes || [];
|
|
919
946
|
var s = createStructure(element);
|
|
920
947
|
element.$struct = s;
|
|
921
948
|
mountElementIds(element, s.ids);
|
|
@@ -923,14 +950,16 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
|
|
|
923
950
|
element.$eval = $eval;
|
|
924
951
|
}
|
|
925
952
|
element.$scope = scope;
|
|
953
|
+
element.$parentScopes = parentScopes || [];
|
|
926
954
|
if (element.$renderid <= -1) element = renderStructure(element);
|
|
927
955
|
if (!element) return;
|
|
928
956
|
if (element.$renderid < 0 || element.nodeType !== 1) {
|
|
929
957
|
return element;
|
|
930
958
|
}
|
|
931
959
|
var isFirstRender = !element.$renderid;
|
|
932
|
-
|
|
933
960
|
if (isFirstRender) {
|
|
961
|
+
var lockid = renderlock.length;
|
|
962
|
+
renderlock[lockid] = null;
|
|
934
963
|
element.$renderid = 1;
|
|
935
964
|
var parentNode = element.parentNode;
|
|
936
965
|
if (parentNode) {
|
|
@@ -960,7 +989,6 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
|
|
|
960
989
|
if (!replacer.$scope) replacer.$scope = scope;
|
|
961
990
|
if (!replacer.$parentScopes) replacer.$parentScopes = parentScopes;
|
|
962
991
|
createStructure(replacer);
|
|
963
|
-
renderArray(getChildren(replacer), replacer.$scope, replacer.$parentScopes, once);
|
|
964
992
|
renderRest(replacer, replacer.$struct);
|
|
965
993
|
}
|
|
966
994
|
copyAttribute(replacer, copys);
|
|
@@ -973,9 +1001,6 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
|
|
|
973
1001
|
}
|
|
974
1002
|
}
|
|
975
1003
|
}
|
|
976
|
-
}
|
|
977
|
-
if (!replacer || element === replacer) renderArray(getChildren(element), scope, parentScopes, once);
|
|
978
|
-
if (isFirstRender) {
|
|
979
1004
|
renderRest(element, $struct, replacer);
|
|
980
1005
|
if (isNode(replacer) && replacer !== element) {
|
|
981
1006
|
if (!replacer.$renders) replacer.$renders = [];
|
|
@@ -984,9 +1009,11 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
|
|
|
984
1009
|
}
|
|
985
1010
|
if (element.$digest || element.$renders.length) {
|
|
986
1011
|
element.$ready = true;
|
|
987
|
-
renderlock
|
|
1012
|
+
renderlock[lockid] = element;
|
|
988
1013
|
}
|
|
1014
|
+
else if (renderlock.length === lockid) renderlock.pop();
|
|
989
1015
|
}
|
|
1016
|
+
renderArray(getChildren(element), element.$scope || scope, element.$parentScopes || parentScopes, once);
|
|
990
1017
|
return element;
|
|
991
1018
|
}
|
|
992
1019
|
var deepcontexts = [];
|
|
@@ -1057,8 +1084,9 @@ var mergeStruct = function (struct1, struct2) {
|
|
|
1057
1084
|
}
|
|
1058
1085
|
|
|
1059
1086
|
class Struct {
|
|
1060
|
-
constructor(
|
|
1061
|
-
this.
|
|
1087
|
+
constructor(emits, onceEmits, types, copys, binds, attrs, props, ids, once) {
|
|
1088
|
+
this.emits = emits;
|
|
1089
|
+
this.waits = onceEmits;
|
|
1062
1090
|
this.if = types.if;
|
|
1063
1091
|
this.repeat = types.repeat;
|
|
1064
1092
|
this.copys = copys;
|
|
@@ -1089,7 +1117,8 @@ function createStructure(element, useExists) {
|
|
|
1089
1117
|
}
|
|
1090
1118
|
var types = {};
|
|
1091
1119
|
var emiter_reg = /^(?:(v|ng|on|once)?\-|v\-on\:|@|once|on)/i;
|
|
1092
|
-
var
|
|
1120
|
+
var emits = {};
|
|
1121
|
+
var waits = {};
|
|
1093
1122
|
var copys = [];
|
|
1094
1123
|
var binds = {};
|
|
1095
1124
|
var once;
|
|
@@ -1175,9 +1204,17 @@ function createStructure(element, useExists) {
|
|
|
1175
1204
|
// ng-click on-click v-click @click @mousedown ...
|
|
1176
1205
|
else if (emiter_reg.test(name)) {
|
|
1177
1206
|
var match = emiter_reg.exec(name);
|
|
1178
|
-
var
|
|
1207
|
+
var isOnce = (match[1] || match[0]).toLowerCase() === 'once';
|
|
1179
1208
|
element.removeAttribute(name);
|
|
1180
|
-
if (value)
|
|
1209
|
+
if (value) {
|
|
1210
|
+
var key = name.replace(emiter_reg, '');
|
|
1211
|
+
if (isOnce) {
|
|
1212
|
+
waits[key] = value;
|
|
1213
|
+
}
|
|
1214
|
+
else {
|
|
1215
|
+
emits[key] = value;
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1181
1218
|
}
|
|
1182
1219
|
// placeholder_ href_ checked_ ...
|
|
1183
1220
|
else if (/[_@\:\.&\?\*\+\#]$/.test(name)) {
|
|
@@ -1226,42 +1263,48 @@ function createStructure(element, useExists) {
|
|
|
1226
1263
|
if (props["zimoli"] || props["fresh"] || props["once"]) once = true;
|
|
1227
1264
|
else if (props["refresh"] || props["digest"] || props["mount"]) once = false;
|
|
1228
1265
|
element.$eval = $eval;
|
|
1229
|
-
return element.$struct = new Struct(
|
|
1266
|
+
return element.$struct = new Struct(emits, waits, types, copys, binds, attr1, props, ids, once);
|
|
1267
|
+
}
|
|
1268
|
+
function unlock(element) {
|
|
1269
|
+
if (!element) return;
|
|
1270
|
+
var { $renderid = 0 } = element;
|
|
1271
|
+
if ($renderid !== 9) {
|
|
1272
|
+
if ($renderid < 10) element.$renderid = ++renderidOffset;
|
|
1273
|
+
on("append")(element, addRenderElement);
|
|
1274
|
+
onremove(element, removeRenderElement);
|
|
1275
|
+
if (element.nodeType === 8);
|
|
1276
|
+
else if (eagermount) buildFirst(element);
|
|
1277
|
+
}
|
|
1278
|
+
else {
|
|
1279
|
+
buildFirst(element);
|
|
1280
|
+
}
|
|
1230
1281
|
}
|
|
1231
|
-
function renderUnlock() {
|
|
1232
|
-
var locked = renderlock
|
|
1282
|
+
function renderUnlock(element) {
|
|
1283
|
+
var locked = renderlock;
|
|
1233
1284
|
renderlock = null;
|
|
1234
|
-
locked.forEach(
|
|
1235
|
-
if (element.$renderid !== 9) {
|
|
1236
|
-
element.$renderid = ++renderidOffset;
|
|
1237
|
-
on("append")(element, addRenderElement);
|
|
1238
|
-
onremove(element, removeRenderElement);
|
|
1239
|
-
if (isMounted(element) || element.nodeType === 8);
|
|
1240
|
-
else if (eagermount) buildFirst(element);
|
|
1241
|
-
}
|
|
1242
|
-
else {
|
|
1243
|
-
buildFirst(element);
|
|
1244
|
-
}
|
|
1245
|
-
});
|
|
1285
|
+
locked.forEach(unlock);
|
|
1246
1286
|
eagermount = false;
|
|
1287
|
+
var parentNode = element.parentNode;
|
|
1288
|
+
if (parentNode && isMounted(parentNode)) appendChild.dispatch(element);
|
|
1247
1289
|
}
|
|
1248
|
-
function renderLock() {
|
|
1290
|
+
function renderLock(element) {
|
|
1249
1291
|
if (!renderlock) {
|
|
1250
1292
|
renderlock = [];
|
|
1293
|
+
element.$mounted = false;
|
|
1251
1294
|
return true;
|
|
1252
1295
|
}
|
|
1253
1296
|
return false;
|
|
1254
1297
|
}
|
|
1255
1298
|
var eagermount = false, renderlock = null;
|
|
1256
1299
|
function render(element, scope, parentScopes, lazy = true) {
|
|
1257
|
-
var haslock = renderLock();
|
|
1300
|
+
var haslock = renderLock(element);
|
|
1258
1301
|
var if_top_length = if_top.length;
|
|
1259
1302
|
if (isFinite(scope) && arguments.length === 2) lazy = scope, scope = undefined;
|
|
1260
1303
|
else if (isFinite(parentScopes) && arguments.length === 3) lazy = parentScopes, parentScopes = undefined;
|
|
1261
1304
|
var renderonce = lazy === 0;
|
|
1262
1305
|
if (haslock) eagermount = !+lazy;
|
|
1263
1306
|
var e = renderElement(element, scope, parentScopes, renderonce);
|
|
1264
|
-
if (if_top_length < if_top.length)
|
|
1307
|
+
if (if_top_length < if_top.length) if_top.splice(if_top_length, if_top.length - if_top_length);
|
|
1265
1308
|
if (haslock) renderUnlock(element);
|
|
1266
1309
|
if (haslock) callDigest();
|
|
1267
1310
|
return e;
|
|
@@ -1297,4 +1340,29 @@ render.getFromScopes = getFromScopes;
|
|
|
1297
1340
|
render.struct = createStructure;
|
|
1298
1341
|
render.mergeStruct = mergeStruct;
|
|
1299
1342
|
render.Binder = Binder;
|
|
1300
|
-
render.Model = Model;
|
|
1343
|
+
render.Model = Model;
|
|
1344
|
+
render.attribute = function (target, attrs) {
|
|
1345
|
+
return renderDynamics(target, target, null, attrs);
|
|
1346
|
+
};
|
|
1347
|
+
render.dynamic = function (target, binds, attrs) {
|
|
1348
|
+
renderBinds(target, binds);
|
|
1349
|
+
renderDynamics(target, target, binds, attrs);
|
|
1350
|
+
};
|
|
1351
|
+
var initRenders = function (target) {
|
|
1352
|
+
if (!target.$renders) target.$renders = [];
|
|
1353
|
+
};
|
|
1354
|
+
render.class = function (target, map) {
|
|
1355
|
+
initRenders(target);
|
|
1356
|
+
directives.class.call(target, map);
|
|
1357
|
+
};
|
|
1358
|
+
render.style = function (target, map) {
|
|
1359
|
+
initRenders(target);
|
|
1360
|
+
directives.style.call(target, map);
|
|
1361
|
+
};
|
|
1362
|
+
render.on = function (target, map) {
|
|
1363
|
+
return renderEmits.call(this, target, map, emiters.on);
|
|
1364
|
+
};
|
|
1365
|
+
render.once = function (target, map) {
|
|
1366
|
+
return renderEmits.call(this, target, map, emiters.once);
|
|
1367
|
+
};
|
|
1368
|
+
render.mount = unlock;
|
|
@@ -182,7 +182,6 @@ function transition(target, _isLeave, _initialStyle) {
|
|
|
182
182
|
else if (isLeave) {
|
|
183
183
|
transitionTimerStart = setTimeout(function () {
|
|
184
184
|
extend(target.style, initialStyle);
|
|
185
|
-
delete target.recoverStyle;
|
|
186
185
|
delete target.captureStyle;
|
|
187
186
|
});
|
|
188
187
|
transitionTimerEnd = setTimeout(function () {
|
|
@@ -198,7 +197,6 @@ function transition(target, _isLeave, _initialStyle) {
|
|
|
198
197
|
if (transitionKey) target.style[transitionKey] = initialStyle[transitionKey];
|
|
199
198
|
target.transitionTimerStart = setTimeout(function () {
|
|
200
199
|
extend(target.style, recoverStyle);
|
|
201
|
-
delete target.recoverStyle;
|
|
202
200
|
delete target.captureStyle;
|
|
203
201
|
}, waitPaint);
|
|
204
202
|
});
|