malinajs 0.7.0-a8 → 0.7.0-a9
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/CHANGELOG.md +12 -0
- package/malina.js +177 -53
- package/package.json +1 -1
- package/runtime.js +51 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
|
|
2
|
+
## 0.7.x
|
|
3
|
+
* refactoring, optimization, fixes
|
|
4
|
+
* export function
|
|
5
|
+
* manual event delegation @click|root
|
|
6
|
+
* able to delay destroying block (for animations)
|
|
7
|
+
* be able to off autosubscribe for import: !no-autosubscribe
|
|
8
|
+
* destructuring array/object for each
|
|
9
|
+
* functions mount, mountStatic
|
|
10
|
+
* each, index variable is not included by default
|
|
11
|
+
* reference to element is removed on destroying
|
|
12
|
+
* config.useGroupReferencing
|
|
13
|
+
|
|
2
14
|
## 0.6.x
|
|
3
15
|
|
|
4
16
|
* style's attribute "global"
|
package/malina.js
CHANGED
|
@@ -196,7 +196,7 @@
|
|
|
196
196
|
|
|
197
197
|
const parseJS = (exp) => {
|
|
198
198
|
let self = {};
|
|
199
|
-
self.ast = acorn.parseExpressionAt(exp, 0, {ecmaVersion: 12});
|
|
199
|
+
self.ast = acorn.parseExpressionAt(exp, 0, { ecmaVersion: 12 });
|
|
200
200
|
|
|
201
201
|
self.transform = function(fn) {
|
|
202
202
|
const rec = (n, pk) => {
|
|
@@ -205,11 +205,11 @@
|
|
|
205
205
|
self = n;
|
|
206
206
|
fn?.(n, pk);
|
|
207
207
|
}
|
|
208
|
-
|
|
208
|
+
|
|
209
209
|
for(let k in n) {
|
|
210
210
|
if(k == '_parent') continue;
|
|
211
211
|
let v = n[k];
|
|
212
|
-
if(v == null || typeof(v) != 'object') continue;
|
|
212
|
+
if(v == null || typeof (v) != 'object') continue;
|
|
213
213
|
if(Array.isArray(v)) {
|
|
214
214
|
v.forEach(i => {
|
|
215
215
|
i._parent = self || n._parent;
|
|
@@ -227,7 +227,7 @@
|
|
|
227
227
|
};
|
|
228
228
|
|
|
229
229
|
self.build = function(data) {
|
|
230
|
-
return astring.generate(data || self.ast, {indent: '', lineEnd: ''});
|
|
230
|
+
return astring.generate(data || self.ast, { indent: '', lineEnd: '' });
|
|
231
231
|
};
|
|
232
232
|
return self;
|
|
233
233
|
};
|
|
@@ -422,7 +422,7 @@
|
|
|
422
422
|
if(_data === false && !_handler) {
|
|
423
423
|
handler = noop;
|
|
424
424
|
data = null;
|
|
425
|
-
} else if(_handler === false && typeof(_data) == 'object') {
|
|
425
|
+
} else if(_handler === false && typeof (_data) == 'object') {
|
|
426
426
|
handler = noop;
|
|
427
427
|
data = _data;
|
|
428
428
|
} else if(typeof _data == 'function') {
|
|
@@ -468,7 +468,7 @@
|
|
|
468
468
|
const resolveDependecies = node => {
|
|
469
469
|
if(node.$wait) {
|
|
470
470
|
node.$wait = node.$wait.map(n => {
|
|
471
|
-
if(typeof(n) == 'string') {
|
|
471
|
+
if(typeof (n) == 'string') {
|
|
472
472
|
const context = get_context();
|
|
473
473
|
assert(context.glob[n], `Wrong dependency '${n}'`);
|
|
474
474
|
n = context.glob[n];
|
|
@@ -479,7 +479,7 @@
|
|
|
479
479
|
|
|
480
480
|
if(node.$hold) {
|
|
481
481
|
node.$hold.forEach(n => {
|
|
482
|
-
if(typeof(n) == 'string') {
|
|
482
|
+
if(typeof (n) == 'string') {
|
|
483
483
|
const context = get_context();
|
|
484
484
|
assert(context.glob[n], `Wrong dependency '${n}'`);
|
|
485
485
|
n = context.glob[n];
|
|
@@ -645,7 +645,8 @@
|
|
|
645
645
|
cloneNode = false;
|
|
646
646
|
if(!node.raw) template = htmlEntitiesToText(template);
|
|
647
647
|
} else {
|
|
648
|
-
convert = '
|
|
648
|
+
if(get_context().config.hideLabel) convert = '$runtime.$$htmlToFragmentClean';
|
|
649
|
+
else convert = '$runtime.$$htmlToFragment';
|
|
649
650
|
template = template.replace(/<!---->/g, '<>');
|
|
650
651
|
}
|
|
651
652
|
if(node.raw) {
|
|
@@ -1303,9 +1304,9 @@
|
|
|
1303
1304
|
}
|
|
1304
1305
|
const onComment = (isBlockComment, value, start, end) => {
|
|
1305
1306
|
if(isBlockComment) return;
|
|
1306
|
-
this.script.comments.push({start, end, value});
|
|
1307
|
+
this.script.comments.push({ start, end, value });
|
|
1307
1308
|
};
|
|
1308
|
-
this.script.ast = acorn.parse(source, {sourceType: 'module', ecmaVersion: 12, onComment});
|
|
1309
|
+
this.script.ast = acorn.parse(source, { sourceType: 'module', ecmaVersion: 12, onComment });
|
|
1309
1310
|
|
|
1310
1311
|
if(source.includes('$props')) this.require('$props');
|
|
1311
1312
|
if(source.includes('$attributes')) this.require('$attributes');
|
|
@@ -1691,8 +1692,7 @@
|
|
|
1691
1692
|
}, (ctx, n) => {
|
|
1692
1693
|
if(!n.list.length) return;
|
|
1693
1694
|
this.require('$component');
|
|
1694
|
-
for(let name of n.list)
|
|
1695
|
-
ctx.write(true, `$component.${name} = ${name};`);
|
|
1695
|
+
for(let name of n.list) ctx.write(true, `$component.${name} = ${name};`);
|
|
1696
1696
|
}));
|
|
1697
1697
|
}
|
|
1698
1698
|
|
|
@@ -1752,7 +1752,7 @@
|
|
|
1752
1752
|
}));
|
|
1753
1753
|
|
|
1754
1754
|
this.module.head.push(xNode('$context', {
|
|
1755
|
-
$hold: ['componentFn']
|
|
1755
|
+
$hold: ['componentFn']
|
|
1756
1756
|
}, (ctx) => {
|
|
1757
1757
|
if(this.inuse.$context) {
|
|
1758
1758
|
this.require('componentFn');
|
|
@@ -2240,26 +2240,152 @@
|
|
|
2240
2240
|
root: option.parentElement,
|
|
2241
2241
|
single: rootTemplate.children.length == 1 && !requireFragment
|
|
2242
2242
|
}, (ctx, n) => {
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
let
|
|
2246
|
-
let
|
|
2243
|
+
if(this.config.useGroupReferencing) {
|
|
2244
|
+
const mark = (node) => {
|
|
2245
|
+
let binding = false;
|
|
2246
|
+
let next = false;
|
|
2247
2247
|
|
|
2248
|
-
if(node._boundName)
|
|
2248
|
+
if(node._boundName) binding = true;
|
|
2249
|
+
|
|
2250
|
+
if(node.children?.length) {
|
|
2251
|
+
let i = node.children.length - 1;
|
|
2252
|
+
for(;i >= 0;i--) {
|
|
2253
|
+
let n = node.children[i];
|
|
2254
|
+
|
|
2255
|
+
if(mark(n)) {
|
|
2256
|
+
if(next) n.bindName();
|
|
2257
|
+
next = true;
|
|
2258
|
+
binding = true;
|
|
2259
|
+
node._innerBinding = true;
|
|
2260
|
+
}
|
|
2261
|
+
}
|
|
2262
|
+
}
|
|
2263
|
+
return binding;
|
|
2264
|
+
};
|
|
2265
|
+
mark(n.tpl);
|
|
2266
|
+
|
|
2267
|
+
const encodeShift = (i) => {
|
|
2268
|
+
if(i <= 42) return String.fromCharCode(48 + i);
|
|
2269
|
+
let b = i % 42;
|
|
2270
|
+
let a = (i - b) / 42;
|
|
2271
|
+
assert(a <= 42, 'Node-shift overflow: ' + i);
|
|
2272
|
+
return '!' + String.fromCharCode(48 + a) + String.fromCharCode(48 + b);
|
|
2273
|
+
};
|
|
2274
|
+
|
|
2275
|
+
const encodeRef = (i) => {
|
|
2276
|
+
if(i <= 26) return String.fromCharCode(97 + i);
|
|
2277
|
+
let b = i % 42;
|
|
2278
|
+
let a = (i - b) / 42;
|
|
2279
|
+
assert(a <= 42, 'Node ref overflow: ' + i);
|
|
2280
|
+
return '#' + String.fromCharCode(48 + a) + String.fromCharCode(48 + b);
|
|
2281
|
+
};
|
|
2282
|
+
|
|
2283
|
+
let result = [];
|
|
2284
|
+
let vars = [];
|
|
2285
|
+
let active = null;
|
|
2286
|
+
|
|
2287
|
+
const walk = (node) => {
|
|
2288
|
+
let shift = 0;
|
|
2289
|
+
let base = null;
|
|
2290
|
+
node.children?.forEach((n, i) => {
|
|
2291
|
+
if(i == 0) {
|
|
2292
|
+
if(n._boundName) {
|
|
2293
|
+
result.push('+');
|
|
2294
|
+
vars.push(n);
|
|
2295
|
+
active = n;
|
|
2296
|
+
walk(n);
|
|
2297
|
+
if(n != active) base = n;
|
|
2298
|
+
} else if(n._innerBinding) {
|
|
2299
|
+
result.push('>');
|
|
2300
|
+
active = n;
|
|
2301
|
+
walk(n);
|
|
2302
|
+
} else if(node._innerBinding) {
|
|
2303
|
+
result.push('>');
|
|
2304
|
+
active = n;
|
|
2305
|
+
walk(n);
|
|
2306
|
+
}
|
|
2307
|
+
} else {
|
|
2308
|
+
if(n._boundName) {
|
|
2309
|
+
if(base) {
|
|
2310
|
+
let x = vars.indexOf(base);
|
|
2311
|
+
result.push(encodeRef(x));
|
|
2312
|
+
base = null;
|
|
2313
|
+
}
|
|
2314
|
+
result.push(encodeShift(shift));
|
|
2315
|
+
result.push('.');
|
|
2316
|
+
shift = 0;
|
|
2317
|
+
active = n;
|
|
2318
|
+
vars.push(n);
|
|
2319
|
+
walk(n);
|
|
2320
|
+
if(n != active) base = n;
|
|
2321
|
+
} else if(n._innerBinding) {
|
|
2322
|
+
if(base) {
|
|
2323
|
+
let x = vars.indexOf(base);
|
|
2324
|
+
result.push(encodeRef(x));
|
|
2325
|
+
base = null;
|
|
2326
|
+
}
|
|
2327
|
+
result.push(encodeShift(shift));
|
|
2328
|
+
active = n;
|
|
2329
|
+
walk(n);
|
|
2330
|
+
}
|
|
2331
|
+
}
|
|
2332
|
+
shift++;
|
|
2333
|
+
});
|
|
2334
|
+
};
|
|
2335
|
+
|
|
2336
|
+
if(n.single) {
|
|
2337
|
+
let node = n.tpl.children[0];
|
|
2338
|
+
if(node._boundName) ctx.write(true, `let ${node._boundName} = ${n.root};`);
|
|
2249
2339
|
if(node.children) {
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2340
|
+
walk(node);
|
|
2341
|
+
if(vars.length) {
|
|
2342
|
+
result = result.join('');
|
|
2343
|
+
vars = vars.map(v => v._boundName).join(', ');
|
|
2344
|
+
ctx.write(true, `let [${vars}] = $runtime.refer(${n.root}, '${result}');`);
|
|
2345
|
+
}
|
|
2346
|
+
}
|
|
2347
|
+
} else {
|
|
2348
|
+
walk(n.tpl);
|
|
2349
|
+
if(vars.length) {
|
|
2350
|
+
result = result.join('');
|
|
2351
|
+
vars = vars.map(v => v._boundName).join(', ');
|
|
2352
|
+
ctx.write(true, `let [${vars}] = $runtime.refer(${n.root}, '${result}');`);
|
|
2254
2353
|
}
|
|
2255
2354
|
}
|
|
2256
|
-
};
|
|
2257
|
-
if(n.single) {
|
|
2258
|
-
let node = n.tpl.children[0];
|
|
2259
|
-
if(node._boundName) ctx.write(true, `let ${node._boundName} = ${n.root};`);
|
|
2260
|
-
if(node.children) gen(node, () => n.root);
|
|
2261
2355
|
} else {
|
|
2262
|
-
|
|
2356
|
+
const walk = p => {
|
|
2357
|
+
if(p.children?.length) {
|
|
2358
|
+
let col = 0;
|
|
2359
|
+
for(let n of p.children) {
|
|
2360
|
+
col += walk(n);
|
|
2361
|
+
}
|
|
2362
|
+
if(col > 1 && !p._boundName) p.bindName();
|
|
2363
|
+
return col ? 1 : 0;
|
|
2364
|
+
} return p._boundName ? 1 : 0;
|
|
2365
|
+
};
|
|
2366
|
+
walk(n.tpl);
|
|
2367
|
+
|
|
2368
|
+
const gen = (parent, parentName) => {
|
|
2369
|
+
for(let i = 0; i < parent.children.length; i++) {
|
|
2370
|
+
let node = parent.children[i];
|
|
2371
|
+
let diff = i == 0 ? '[$runtime.firstChild]' : `[$runtime.childNodes][${i}]`;
|
|
2372
|
+
|
|
2373
|
+
if(node._boundName) ctx.write(true, `let ${node._boundName} = ${parentName() + diff};`);
|
|
2374
|
+
if(node.children) {
|
|
2375
|
+
gen(node, () => {
|
|
2376
|
+
if(node._boundName) return node._boundName;
|
|
2377
|
+
return parentName() + diff;
|
|
2378
|
+
});
|
|
2379
|
+
}
|
|
2380
|
+
}
|
|
2381
|
+
};
|
|
2382
|
+
if(n.single) {
|
|
2383
|
+
let node = n.tpl.children[0];
|
|
2384
|
+
if(node._boundName) ctx.write(true, `let ${node._boundName} = ${n.root};`);
|
|
2385
|
+
if(node.children) gen(node, () => n.root);
|
|
2386
|
+
} else {
|
|
2387
|
+
gen(n.tpl, () => n.root);
|
|
2388
|
+
}
|
|
2263
2389
|
}
|
|
2264
2390
|
}));
|
|
2265
2391
|
}
|
|
@@ -4837,10 +4963,11 @@
|
|
|
4837
4963
|
if(comma) ctx.write(', ');
|
|
4838
4964
|
comma = true;
|
|
4839
4965
|
ctx.write('events: $events');
|
|
4840
|
-
} else if(n.events
|
|
4966
|
+
} else if(n.events) {
|
|
4841
4967
|
if(comma) ctx.write(',', true);
|
|
4842
4968
|
comma = true;
|
|
4843
|
-
ctx.write('events: {');
|
|
4969
|
+
if(n.forwardAllEvents) ctx.write('events: $runtime.mergeAllEvents($events, {');
|
|
4970
|
+
else ctx.write('events: {');
|
|
4844
4971
|
ctx.indent++;
|
|
4845
4972
|
ctx.write(true);
|
|
4846
4973
|
Object.entries(n.events).forEach(([event, list], index) => {
|
|
@@ -4857,9 +4984,8 @@
|
|
|
4857
4984
|
}
|
|
4858
4985
|
});
|
|
4859
4986
|
ctx.indent--;
|
|
4860
|
-
ctx.write(true, '}');
|
|
4861
|
-
|
|
4862
|
-
throw 'not implemented'; // FIXME
|
|
4987
|
+
if(n.forwardAllEvents) ctx.write(true, '})');
|
|
4988
|
+
else ctx.write(true, '}');
|
|
4863
4989
|
}
|
|
4864
4990
|
if(n.slots) {
|
|
4865
4991
|
if(comma) ctx.write(', ');
|
|
@@ -4944,7 +5070,7 @@
|
|
|
4944
5070
|
this.require('apply');
|
|
4945
5071
|
this.detectDependency(dynamicComponent);
|
|
4946
5072
|
|
|
4947
|
-
let {bind: component, reference} = this.makeComponent(node);
|
|
5073
|
+
let { bind: component, reference } = this.makeComponent(node);
|
|
4948
5074
|
|
|
4949
5075
|
component.componentName = '$ComponentConstructor';
|
|
4950
5076
|
return xNode('dyn-component', {
|
|
@@ -5025,13 +5151,15 @@
|
|
|
5025
5151
|
if(name[0] == '#') {
|
|
5026
5152
|
let target = name.substring(1);
|
|
5027
5153
|
assert(detectExpressionType(target) == 'identifier', name);
|
|
5028
|
-
return {
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
ctx
|
|
5033
|
-
|
|
5034
|
-
|
|
5154
|
+
return {
|
|
5155
|
+
bind: xNode('reference-to-element', {
|
|
5156
|
+
target,
|
|
5157
|
+
el: element.bindName()
|
|
5158
|
+
}, (ctx, n) => {
|
|
5159
|
+
ctx.write(true, `${n.target} = ${n.el};`);
|
|
5160
|
+
ctx.write(true, `$runtime.$onDestroy(() => ${n.target} = null);`);
|
|
5161
|
+
})
|
|
5162
|
+
};
|
|
5035
5163
|
} else if(name == 'event') {
|
|
5036
5164
|
if(prop.name.startsWith('@@')) {
|
|
5037
5165
|
assert(!prop.value);
|
|
@@ -5542,7 +5670,7 @@
|
|
|
5542
5670
|
if(keyName) {
|
|
5543
5671
|
if(keyName == itemName) keyFunction = 'noop';
|
|
5544
5672
|
else {
|
|
5545
|
-
let keyLink = {[itemName]: '$$item'};
|
|
5673
|
+
let keyLink = { [itemName]: '$$item' };
|
|
5546
5674
|
if(indexName) keyLink[indexName] = '$index';
|
|
5547
5675
|
makeKeyFunction(keyLink);
|
|
5548
5676
|
}
|
|
@@ -5587,7 +5715,7 @@
|
|
|
5587
5715
|
}, (ctx, n) => {
|
|
5588
5716
|
ctx.write(`$runtime.makeEachSingleBlock((${n.itemName}`);
|
|
5589
5717
|
if(n.indexName) ctx.write(`, ${n.indexName}`);
|
|
5590
|
-
ctx.write(
|
|
5718
|
+
ctx.write(') => [');
|
|
5591
5719
|
ctx.indent++;
|
|
5592
5720
|
ctx.write(true);
|
|
5593
5721
|
if(n.rebind) ctx.add(n.rebind);
|
|
@@ -5731,7 +5859,7 @@
|
|
|
5731
5859
|
name: slotName,
|
|
5732
5860
|
props,
|
|
5733
5861
|
staticProps,
|
|
5734
|
-
placeholder
|
|
5862
|
+
placeholder
|
|
5735
5863
|
}, (ctx, n) => {
|
|
5736
5864
|
let dynamicProps = this.inuse.apply && !n.staticProps;
|
|
5737
5865
|
|
|
@@ -6354,7 +6482,7 @@
|
|
|
6354
6482
|
return { event, fn, rootModifier };
|
|
6355
6483
|
}
|
|
6356
6484
|
|
|
6357
|
-
const version = '0.7.0-
|
|
6485
|
+
const version = '0.7.0-a9';
|
|
6358
6486
|
|
|
6359
6487
|
|
|
6360
6488
|
async function compile(source, config = {}) {
|
|
@@ -6372,7 +6500,8 @@
|
|
|
6372
6500
|
debug: true,
|
|
6373
6501
|
css: true,
|
|
6374
6502
|
passClass: true,
|
|
6375
|
-
immutable: false
|
|
6503
|
+
immutable: false,
|
|
6504
|
+
useGroupReferencing: true
|
|
6376
6505
|
}, config);
|
|
6377
6506
|
|
|
6378
6507
|
const ctx = {
|
|
@@ -6497,11 +6626,6 @@
|
|
|
6497
6626
|
const result = ctx.result = xNode('block');
|
|
6498
6627
|
result.push('import * as $runtime from \'malinajs/runtime.js\';');
|
|
6499
6628
|
result.push('import { $watch, $tick } from \'malinajs/runtime.js\';');
|
|
6500
|
-
if(config.hideLabel) {
|
|
6501
|
-
result.push('import { $$htmlToFragmentClean as $$htmlToFragment } from \'malinajs/runtime.js\';');
|
|
6502
|
-
} else {
|
|
6503
|
-
result.push('import { $$htmlToFragment } from \'malinajs/runtime.js\';');
|
|
6504
|
-
}
|
|
6505
6629
|
result.push(ctx.module.top);
|
|
6506
6630
|
result.push(xNode('componentFn-wrapper', {
|
|
6507
6631
|
$compile: [ctx.module.head, ctx.module.code, ctx.module.body, ctx.glob.rootCD],
|
|
@@ -6512,7 +6636,7 @@
|
|
|
6512
6636
|
else ctx.write(true, `const ${n.name} = `);
|
|
6513
6637
|
ctx.add(n.componentFn);
|
|
6514
6638
|
}));
|
|
6515
|
-
|
|
6639
|
+
|
|
6516
6640
|
ctx.result = xBuild(result);
|
|
6517
6641
|
});
|
|
6518
6642
|
|
|
@@ -6565,7 +6689,7 @@
|
|
|
6565
6689
|
|
|
6566
6690
|
if(localConfig) {
|
|
6567
6691
|
const confFn = require(localConfig);
|
|
6568
|
-
if(typeof(confFn) == 'function') result = confFn(result, filename);
|
|
6692
|
+
if(typeof (confFn) == 'function') result = confFn(result, filename);
|
|
6569
6693
|
else result = confFn;
|
|
6570
6694
|
}
|
|
6571
6695
|
if(!result.path) result.path = filename;
|
package/package.json
CHANGED
package/runtime.js
CHANGED
|
@@ -432,7 +432,7 @@ const callComponent = (context, component, option = {}, propFn, cmp, setter, cla
|
|
|
432
432
|
option.props = parentWatch.fn();
|
|
433
433
|
$component.push();
|
|
434
434
|
});
|
|
435
|
-
Object.assign(w, {idle: true, cmp, value: parentWatch.value});
|
|
435
|
+
Object.assign(w, { idle: true, cmp, value: parentWatch.value });
|
|
436
436
|
$component.$cd.watchers.push(w);
|
|
437
437
|
}
|
|
438
438
|
|
|
@@ -632,7 +632,7 @@ const makeAnchor = (fn) => {
|
|
|
632
632
|
} finally {
|
|
633
633
|
current_cd = prev;
|
|
634
634
|
}
|
|
635
|
-
}
|
|
635
|
+
};
|
|
636
636
|
};
|
|
637
637
|
|
|
638
638
|
|
|
@@ -737,7 +737,7 @@ const makeBlockBound = (fr, fn) => {
|
|
|
737
737
|
} finally {
|
|
738
738
|
current_cd = prev;
|
|
739
739
|
}
|
|
740
|
-
}
|
|
740
|
+
};
|
|
741
741
|
};
|
|
742
742
|
|
|
743
743
|
|
|
@@ -751,6 +751,15 @@ const mergeEvents = (...callbacks) => {
|
|
|
751
751
|
return (e) => callbacks.forEach(cb => cb(e));
|
|
752
752
|
};
|
|
753
753
|
|
|
754
|
+
const mergeAllEvents = ($events, local) => {
|
|
755
|
+
let result = Object.assign({}, $events);
|
|
756
|
+
for(let e in local) {
|
|
757
|
+
if(result[e]) result[e] = mergeEvents($events[e], local[e]);
|
|
758
|
+
else result[e] = local[e];
|
|
759
|
+
}
|
|
760
|
+
return result;
|
|
761
|
+
};
|
|
762
|
+
|
|
754
763
|
const makeRootEvent = (root) => {
|
|
755
764
|
let events = {}, nodes = [];
|
|
756
765
|
|
|
@@ -817,6 +826,40 @@ const mountStatic = (label, component, option) => {
|
|
|
817
826
|
}
|
|
818
827
|
};
|
|
819
828
|
|
|
829
|
+
const refer = (active, line) => {
|
|
830
|
+
let result = [], i, v;
|
|
831
|
+
const code = (x, d) => x.charCodeAt() - d;
|
|
832
|
+
|
|
833
|
+
for(i = 0; i < line.length; i++) {
|
|
834
|
+
let a = line[i];
|
|
835
|
+
switch (a) {
|
|
836
|
+
case '>':
|
|
837
|
+
active = active.firstChild;
|
|
838
|
+
break;
|
|
839
|
+
case '+':
|
|
840
|
+
active = active.firstChild;
|
|
841
|
+
case '.':
|
|
842
|
+
result.push(active);
|
|
843
|
+
break;
|
|
844
|
+
case '!':
|
|
845
|
+
v = code(line[++i], 48) * 42 + code(line[++i], 48);
|
|
846
|
+
while(v--) active = active.nextSibling;
|
|
847
|
+
break;
|
|
848
|
+
case '#':
|
|
849
|
+
active = result[code(line[++i], 48) * 26 + code(line[++i], 48)];
|
|
850
|
+
break;
|
|
851
|
+
default:
|
|
852
|
+
v = code(a, 0);
|
|
853
|
+
if(v >= 97) active = result[v - 97];
|
|
854
|
+
else {
|
|
855
|
+
v -= 48;
|
|
856
|
+
while(v--) active = active.nextSibling;
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
return result;
|
|
861
|
+
};
|
|
862
|
+
|
|
820
863
|
let create = (tag, html) => {
|
|
821
864
|
let fr;
|
|
822
865
|
if(tag.parentElement instanceof SVGElement) {
|
|
@@ -1108,14 +1151,14 @@ function $$eachBlock(label, onlyChild, fn, getKey, bind) {
|
|
|
1108
1151
|
d = current_destroyList = [],
|
|
1109
1152
|
$cd = current_cd = cd_new();
|
|
1110
1153
|
try {
|
|
1111
|
-
([
|
|
1154
|
+
([$dom, rebind] = bind(item, i));
|
|
1112
1155
|
} finally {
|
|
1113
1156
|
current_destroyList = null;
|
|
1114
1157
|
current_cd = null;
|
|
1115
1158
|
}
|
|
1116
1159
|
if(d.length) p_destroy = 1;
|
|
1117
1160
|
else d = null;
|
|
1118
|
-
ctx = {$cd, d, rebind};
|
|
1161
|
+
ctx = { $cd, d, rebind };
|
|
1119
1162
|
cd_attach2(eachCD, $cd);
|
|
1120
1163
|
if($dom.nodeType == 11) {
|
|
1121
1164
|
ctx.first = $dom[firstChild];
|
|
@@ -1142,7 +1185,7 @@ const invokeSlot = ($component, slotName, $context, propsFn, placeholder, cmp) =
|
|
|
1142
1185
|
|
|
1143
1186
|
if($slot) {
|
|
1144
1187
|
let push, w = new WatchObject(propsFn, value => push(value));
|
|
1145
|
-
Object.assign(w, {value: {}, cmp, idle: true});
|
|
1188
|
+
Object.assign(w, { value: {}, cmp, idle: true });
|
|
1146
1189
|
fire(w);
|
|
1147
1190
|
let $dom = $slot($component, $context, w.value);
|
|
1148
1191
|
if($dom.$dom) {
|
|
@@ -1164,11 +1207,11 @@ const makeSlot = (fr, fn) => {
|
|
|
1164
1207
|
$onDestroy(() => cd_detach($cd));
|
|
1165
1208
|
parentCD.component.apply();
|
|
1166
1209
|
try {
|
|
1167
|
-
return {$dom, push: fn($dom, $context, callerComponent, props)};
|
|
1210
|
+
return { $dom, push: fn($dom, $context, callerComponent, props) };
|
|
1168
1211
|
} finally {
|
|
1169
1212
|
current_cd = prev;
|
|
1170
1213
|
}
|
|
1171
1214
|
};
|
|
1172
1215
|
};
|
|
1173
1216
|
|
|
1174
|
-
export { $$addEventForComponent, $$awaitBlock, $$cloneDeep, $$compareArray, $$compareDeep, $$deepComparator, $$eachBlock, $$htmlBlock, $$htmlBlockStatic, $$htmlToFragment, $$htmlToFragmentClean, $$removeElements, $$removeItem, $context, $digest, $makeEmitter, $onDestroy, $onMount, $tick, $watch, WatchObject, __app_onerror, __bindActionSubscribe, addClass, addEvent, addStyles, attachAnchor, attachBlock, attachDynComponent, autoSubscribe, bindAction, bindAttribute, bindAttributeBase, bindClass, bindClassExp, bindInput, bindStyle, bindText, callComponent, callExportedFragment, cd_attach, cd_attach2, cd_component, cd_detach, cd_new, childNodes, cloneDeep, configure, createTextNode, current_cd, current_component, current_destroyList, destroyResults, eachDefaultKey, exportFragment, fire, firstChild, getFinalLabel, ifBlock, ifBlockReadOnly, insertAfter, invokeSlot, invokeSlotBase, isArray, isFunction, iterNodes, keyComparator, makeAnchor, makeApply, makeBlock, makeBlockBound, makeClassResolver, makeComponent, makeEachBlock, makeEachSingleBlock, makeExternalProperty, makeRootEvent, makeSlot, mergeEvents, mount, mountStatic, noop, prefixPush, removeElementsBetween, setClassToElement, spreadAttributes, svgToFragment, unwrapProps };
|
|
1217
|
+
export { $$addEventForComponent, $$awaitBlock, $$cloneDeep, $$compareArray, $$compareDeep, $$deepComparator, $$eachBlock, $$htmlBlock, $$htmlBlockStatic, $$htmlToFragment, $$htmlToFragmentClean, $$removeElements, $$removeItem, $context, $digest, $makeEmitter, $onDestroy, $onMount, $tick, $watch, WatchObject, __app_onerror, __bindActionSubscribe, addClass, addEvent, addStyles, attachAnchor, attachBlock, attachDynComponent, autoSubscribe, bindAction, bindAttribute, bindAttributeBase, bindClass, bindClassExp, bindInput, bindStyle, bindText, callComponent, callExportedFragment, cd_attach, cd_attach2, cd_component, cd_detach, cd_new, childNodes, cloneDeep, configure, createTextNode, current_cd, current_component, current_destroyList, destroyResults, eachDefaultKey, exportFragment, fire, firstChild, getFinalLabel, ifBlock, ifBlockReadOnly, insertAfter, invokeSlot, invokeSlotBase, isArray, isFunction, iterNodes, keyComparator, makeAnchor, makeApply, makeBlock, makeBlockBound, makeClassResolver, makeComponent, makeEachBlock, makeEachSingleBlock, makeExternalProperty, makeRootEvent, makeSlot, mergeAllEvents, mergeEvents, mount, mountStatic, noop, prefixPush, refer, removeElementsBetween, setClassToElement, spreadAttributes, svgToFragment, unwrapProps };
|