efront 4.12.0 → 4.12.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.
|
@@ -156,7 +156,7 @@ macros.calc = function (a) {
|
|
|
156
156
|
};
|
|
157
157
|
macros.range = function () {
|
|
158
158
|
if (arguments.length === 1) {
|
|
159
|
-
return ArrayFill(arguments[0], 0).map((a, i) => i + 1);
|
|
159
|
+
return ArrayFill(arguments[0], 0).map((a, i) => i + 1).join(' ');
|
|
160
160
|
}
|
|
161
161
|
if (arguments.length === 3) {
|
|
162
162
|
var [start, end, step] = arguments;
|
|
@@ -173,22 +173,26 @@ macros.range = function () {
|
|
|
173
173
|
end = parseFloat(end);
|
|
174
174
|
step = parseFloat(step) || 1;
|
|
175
175
|
var result = [];
|
|
176
|
-
for (var temp = start; temp
|
|
177
|
-
result.push(temp.toFixed(fixed) + unit);
|
|
176
|
+
for (var temp = start; temp <= end; temp += step) {
|
|
177
|
+
result.push(+temp.toFixed(fixed) + unit);
|
|
178
178
|
}
|
|
179
|
-
return result;
|
|
179
|
+
return result.join(' ');
|
|
180
180
|
}
|
|
181
181
|
throw new Error(i18n`range参数错误:` + arguments);
|
|
182
182
|
};
|
|
183
|
-
macros.extract = function (
|
|
184
|
-
if (
|
|
183
|
+
macros.extract = function () {
|
|
184
|
+
if (arguments.length === 2) var [list, index] = arguments;
|
|
185
|
+
else var index = arguments[arguments.length - 1], list = Array.prototype.slice.call(arguments, 0, arguments.length - 1);
|
|
186
|
+
index -= 1;
|
|
187
|
+
if (typeof list === 'string') list = getList(list);
|
|
185
188
|
else if (list instanceof Array) {
|
|
186
|
-
list =
|
|
189
|
+
list = list.concat(list.rest);
|
|
187
190
|
}
|
|
188
191
|
return list[index];
|
|
189
192
|
};
|
|
190
193
|
macros.length = function (list) {
|
|
191
|
-
if (
|
|
194
|
+
if (arguments.length !== 1) return arguments.length;
|
|
195
|
+
if (typeof list === 'string') return getList(list).length;
|
|
192
196
|
else if (list instanceof Array) {
|
|
193
197
|
return createArgMap(list.concat(list.rest).join(''), ';').length;
|
|
194
198
|
}
|
|
@@ -202,6 +206,7 @@ macros.escape = function (a) {
|
|
|
202
206
|
macros.e = function (a) {
|
|
203
207
|
return strings.decode(a);
|
|
204
208
|
};
|
|
209
|
+
|
|
205
210
|
var wrapColor = function (k) {
|
|
206
211
|
var f = color[k];
|
|
207
212
|
macros[k] = function (c) {
|
|
@@ -231,6 +236,11 @@ macros[""] = function (a) {
|
|
|
231
236
|
return a;
|
|
232
237
|
};
|
|
233
238
|
|
|
239
|
+
var getList = function (list) {
|
|
240
|
+
list = splitParams(list);
|
|
241
|
+
if (list.length === 1) list = list[0].split(/\s+/);
|
|
242
|
+
return list;
|
|
243
|
+
};
|
|
234
244
|
macros.each = function () {
|
|
235
245
|
if (arguments.length !== 2) {
|
|
236
246
|
body = arguments[arguments.length - 1];
|
|
@@ -248,7 +258,7 @@ macros.each = function () {
|
|
|
248
258
|
if (args.length < 1) args.push("@value");
|
|
249
259
|
if (args.length < 2) args.push("@key");
|
|
250
260
|
if (args.length < 3) args.push("@index");
|
|
251
|
-
if (typeof list === "string") list =
|
|
261
|
+
if (typeof list === "string") list = getList(list);
|
|
252
262
|
else if (list instanceof Array) {
|
|
253
263
|
list = createArgMap(list.concat(list.rest).join(""), ';');
|
|
254
264
|
}
|
|
@@ -78,6 +78,14 @@ assert(素馨(`a{filter:grayscale(.9)}`), `a{filter:grayscale(.9);}`);
|
|
|
78
78
|
assert(素馨(`a{each(1,2,3,4,5,(@a){a:@a})}`), `a{a:1;a:2;a:3;a:4;a:5;}`);
|
|
79
79
|
assert(素馨(`each(1,(@a){a{a:@a}})a>b{b:2}`), `a{a:1;}\r\na>b{b:2;}`);
|
|
80
80
|
assert(素馨(`each(2,(@a){@b:1/@a;a{a:@b}})`), `a{a:0.5;}`);
|
|
81
|
+
assert(素馨(`each(2,.(@a){@b:1/@a;a{a:@b}})`), `a{a:0.5;}`);
|
|
82
|
+
assert(素馨(`a{a:length(2)}`), `a{a:1;}`);
|
|
83
|
+
assert(素馨(`a{b:length(2,3)}`), `a{b:2;}`);
|
|
84
|
+
assert(素馨(`a{a:extract(2,1)}`), `a{a:2;}`);
|
|
85
|
+
assert(素馨(`a{a:extract(2,3,2)}`), `a{a:3;}`);
|
|
86
|
+
assert(素馨(`a{a:extract(2 3,2)}`), `a{a:3;}`);
|
|
87
|
+
assert(素馨(`value: range(10px, 30px, 10);`, '', true), `value:10px 20px 30px;`);
|
|
88
|
+
assert(素馨(`value: range(4);`, '', true), `value:1 2 3 4;`);
|
|
81
89
|
assert(scanner2(`-0.2em .3em -0.2em 0`, new 素馨.素心)[0].text, '-0.2em');
|
|
82
90
|
assert(scanner2(`-0.2em .3em -0.2em 0`, new 素馨.素心)[0].isdigit, true);
|
|
83
91
|
assert(scanner2(`-0.2em .3em -0.2em 0`, new 素馨.素心)[2].text, ".3em");
|
package/coms/zimoli/render.js
CHANGED
|
@@ -41,6 +41,7 @@ presets.template = function (t) {
|
|
|
41
41
|
var comment = document.createComment('template');
|
|
42
42
|
comment.$scope = t.$scope;
|
|
43
43
|
comment.$parentScopes = t.$parentScopes;
|
|
44
|
+
t.$comment = comment;
|
|
44
45
|
if (t.$struct.binds.src) {
|
|
45
46
|
care(comment, createTemplateNodes)
|
|
46
47
|
}
|
|
@@ -274,7 +275,9 @@ var createRepeat = function (search, id = 0) {
|
|
|
274
275
|
for (var k in clonedElements) {
|
|
275
276
|
if (clonedElements1[k] !== clonedElements[k]) {
|
|
276
277
|
var selected = clonedElements[k].selected;
|
|
277
|
-
|
|
278
|
+
var c = clonedElements[k];
|
|
279
|
+
if (!c.parentNode && c.$comment) remove(c.$comment);
|
|
280
|
+
else remove(clonedElements[k]);
|
|
278
281
|
if (selected) { clonedElements1[k].selected = true; }
|
|
279
282
|
}
|
|
280
283
|
}
|