mol_wire_lib 1.0.196 → 1.0.197
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/node.test.js +114 -12
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.test.js +114 -12
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -2334,28 +2334,52 @@ var $;
|
|
|
2334
2334
|
const Button = (props, target) => {
|
|
2335
2335
|
return $mol_jsx("button", { title: props.hint }, target());
|
|
2336
2336
|
};
|
|
2337
|
-
const dom = $mol_jsx(Button, { id: "
|
|
2338
|
-
$mol_assert_equal(dom.outerHTML, '<button title="click me" id="
|
|
2337
|
+
const dom = $mol_jsx(Button, { id: "foo", hint: "click me" }, () => 'hey!');
|
|
2338
|
+
$mol_assert_equal(dom.outerHTML, '<button title="click me" id="foo" class="Button">hey!</button>');
|
|
2339
2339
|
},
|
|
2340
2340
|
'Nested guid generation'() {
|
|
2341
2341
|
const Foo = () => {
|
|
2342
2342
|
return $mol_jsx("div", null,
|
|
2343
|
-
$mol_jsx(Bar, { id: "
|
|
2344
|
-
$mol_jsx("img", { id: "
|
|
2343
|
+
$mol_jsx(Bar, { id: "bar" },
|
|
2344
|
+
$mol_jsx("img", { id: "icon" })));
|
|
2345
2345
|
};
|
|
2346
2346
|
const Bar = (props, icon) => {
|
|
2347
|
-
return $mol_jsx("span", null,
|
|
2347
|
+
return $mol_jsx("span", null,
|
|
2348
|
+
icon,
|
|
2349
|
+
$mol_jsx("i", { id: "label" }));
|
|
2348
2350
|
};
|
|
2349
|
-
const dom = $mol_jsx(Foo, { id: "
|
|
2350
|
-
$mol_assert_equal(dom.outerHTML, '<div id="
|
|
2351
|
+
const dom = $mol_jsx(Foo, { id: "foo" });
|
|
2352
|
+
$mol_assert_equal(dom.outerHTML, '<div id="foo" class="Foo"><span id="foo/bar" class="Foo_bar Bar"><img id="foo/icon" class="Foo_icon"><i id="foo/bar/label" class="Foo_bar_label Bar_label"></i></span></div>');
|
|
2351
2353
|
},
|
|
2352
2354
|
'Fail on non unique ids'() {
|
|
2353
2355
|
const App = () => {
|
|
2354
2356
|
return $mol_jsx("div", null,
|
|
2355
|
-
$mol_jsx("span", { id: "
|
|
2356
|
-
$mol_jsx("span", { id: "
|
|
2357
|
+
$mol_jsx("span", { id: "bar" }),
|
|
2358
|
+
$mol_jsx("span", { id: "bar" }));
|
|
2357
2359
|
};
|
|
2358
|
-
$mol_assert_fail(() => $mol_jsx(App, { id: "
|
|
2360
|
+
$mol_assert_fail(() => $mol_jsx(App, { id: "foo" }), 'JSX already has tag with id "foo/bar"');
|
|
2361
|
+
},
|
|
2362
|
+
'Owner based guid generationn'() {
|
|
2363
|
+
const Foo = () => {
|
|
2364
|
+
return $mol_jsx("div", null,
|
|
2365
|
+
$mol_jsx(Bar, { id: "middle", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
|
2366
|
+
};
|
|
2367
|
+
const Bar = (props) => {
|
|
2368
|
+
return $mol_jsx("span", null, props.icon());
|
|
2369
|
+
};
|
|
2370
|
+
const dom = $mol_jsx(Foo, { id: "app" });
|
|
2371
|
+
$mol_assert_equal(dom.outerHTML, '<div id="app" class="Foo"><span id="app/middle" class="Foo_middle Bar"><img id="app/icon" class="Foo_icon"></span></div>');
|
|
2372
|
+
},
|
|
2373
|
+
'Fail on same ids from different caller'() {
|
|
2374
|
+
const Foo = () => {
|
|
2375
|
+
return $mol_jsx("div", null,
|
|
2376
|
+
$mol_jsx("img", { id: "icon" }),
|
|
2377
|
+
$mol_jsx(Bar, { id: "bar", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
|
2378
|
+
};
|
|
2379
|
+
const Bar = (props) => {
|
|
2380
|
+
return $mol_jsx("span", null, props.icon());
|
|
2381
|
+
};
|
|
2382
|
+
$mol_assert_fail(() => $mol_jsx(Foo, { id: "foo" }), 'JSX already has tag with id "foo/icon"');
|
|
2359
2383
|
},
|
|
2360
2384
|
});
|
|
2361
2385
|
})($ || ($ = {}));
|
|
@@ -2365,6 +2389,7 @@ var $;
|
|
|
2365
2389
|
var $;
|
|
2366
2390
|
(function ($) {
|
|
2367
2391
|
$.$mol_jsx_prefix = '';
|
|
2392
|
+
$.$mol_jsx_crumbs = '';
|
|
2368
2393
|
$.$mol_jsx_booked = null;
|
|
2369
2394
|
$.$mol_jsx_document = {
|
|
2370
2395
|
getElementById: () => null,
|
|
@@ -2374,16 +2399,45 @@ var $;
|
|
|
2374
2399
|
$.$mol_jsx_frag = '';
|
|
2375
2400
|
function $mol_jsx(Elem, props, ...childNodes) {
|
|
2376
2401
|
const id = props && props.id || '';
|
|
2402
|
+
const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
|
|
2403
|
+
const crumbs_self = id ? $.$mol_jsx_crumbs.replace(/(\S+)/g, `$1_${id}`) : $.$mol_jsx_crumbs;
|
|
2377
2404
|
if (Elem && $.$mol_jsx_booked) {
|
|
2378
2405
|
if ($.$mol_jsx_booked.has(id)) {
|
|
2379
|
-
$mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(
|
|
2406
|
+
$mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`));
|
|
2380
2407
|
}
|
|
2381
2408
|
else {
|
|
2382
2409
|
$.$mol_jsx_booked.add(id);
|
|
2383
2410
|
}
|
|
2384
2411
|
}
|
|
2385
|
-
const guid = $.$mol_jsx_prefix + id;
|
|
2386
2412
|
let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
|
|
2413
|
+
if ($.$mol_jsx_prefix) {
|
|
2414
|
+
const prefix_ext = $.$mol_jsx_prefix;
|
|
2415
|
+
const booked_ext = $.$mol_jsx_booked;
|
|
2416
|
+
const crumbs_ext = $.$mol_jsx_crumbs;
|
|
2417
|
+
for (const field in props) {
|
|
2418
|
+
const func = props[field];
|
|
2419
|
+
if (typeof func !== 'function')
|
|
2420
|
+
continue;
|
|
2421
|
+
const wrapper = function (...args) {
|
|
2422
|
+
const prefix = $.$mol_jsx_prefix;
|
|
2423
|
+
const booked = $.$mol_jsx_booked;
|
|
2424
|
+
const crumbs = $.$mol_jsx_crumbs;
|
|
2425
|
+
try {
|
|
2426
|
+
$.$mol_jsx_prefix = prefix_ext;
|
|
2427
|
+
$.$mol_jsx_booked = booked_ext;
|
|
2428
|
+
$.$mol_jsx_crumbs = crumbs_ext;
|
|
2429
|
+
return func.call(this, ...args);
|
|
2430
|
+
}
|
|
2431
|
+
finally {
|
|
2432
|
+
$.$mol_jsx_prefix = prefix;
|
|
2433
|
+
$.$mol_jsx_booked = booked;
|
|
2434
|
+
$.$mol_jsx_crumbs = crumbs;
|
|
2435
|
+
}
|
|
2436
|
+
};
|
|
2437
|
+
$mol_func_name_from(wrapper, func);
|
|
2438
|
+
props[field] = wrapper;
|
|
2439
|
+
}
|
|
2440
|
+
}
|
|
2387
2441
|
if (typeof Elem !== 'string') {
|
|
2388
2442
|
if ('prototype' in Elem) {
|
|
2389
2443
|
const view = node && node[Elem] || new Elem;
|
|
@@ -2392,6 +2446,7 @@ var $;
|
|
|
2392
2446
|
view.childNodes = childNodes;
|
|
2393
2447
|
if (!view.ownerDocument)
|
|
2394
2448
|
view.ownerDocument = $.$mol_jsx_document;
|
|
2449
|
+
view.className = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
|
|
2395
2450
|
node = view.valueOf();
|
|
2396
2451
|
node[Elem] = view;
|
|
2397
2452
|
return node;
|
|
@@ -2399,14 +2454,17 @@ var $;
|
|
|
2399
2454
|
else {
|
|
2400
2455
|
const prefix = $.$mol_jsx_prefix;
|
|
2401
2456
|
const booked = $.$mol_jsx_booked;
|
|
2457
|
+
const crumbs = $.$mol_jsx_crumbs;
|
|
2402
2458
|
try {
|
|
2403
2459
|
$.$mol_jsx_prefix = guid;
|
|
2404
2460
|
$.$mol_jsx_booked = new Set;
|
|
2461
|
+
$.$mol_jsx_crumbs = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
|
|
2405
2462
|
return Elem(props, ...childNodes);
|
|
2406
2463
|
}
|
|
2407
2464
|
finally {
|
|
2408
2465
|
$.$mol_jsx_prefix = prefix;
|
|
2409
2466
|
$.$mol_jsx_booked = booked;
|
|
2467
|
+
$.$mol_jsx_crumbs = crumbs;
|
|
2410
2468
|
}
|
|
2411
2469
|
}
|
|
2412
2470
|
}
|
|
@@ -2437,6 +2495,8 @@ var $;
|
|
|
2437
2495
|
}
|
|
2438
2496
|
if (guid)
|
|
2439
2497
|
node.id = guid;
|
|
2498
|
+
if ($.$mol_jsx_crumbs)
|
|
2499
|
+
node.className = (props?.['class'] ? props['class'] + ' ' : '') + crumbs_self;
|
|
2440
2500
|
return node;
|
|
2441
2501
|
}
|
|
2442
2502
|
$.$mol_jsx = $mol_jsx;
|
|
@@ -2803,6 +2863,48 @@ var $;
|
|
|
2803
2863
|
;
|
|
2804
2864
|
"use strict";
|
|
2805
2865
|
var $;
|
|
2866
|
+
(function ($_1) {
|
|
2867
|
+
$mol_test({
|
|
2868
|
+
'FQN of anon function'($) {
|
|
2869
|
+
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
2870
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
2871
|
+
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
2872
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
2873
|
+
},
|
|
2874
|
+
});
|
|
2875
|
+
})($ || ($ = {}));
|
|
2876
|
+
//mol/func/name/name.test.ts
|
|
2877
|
+
;
|
|
2878
|
+
"use strict";
|
|
2879
|
+
var $;
|
|
2880
|
+
(function ($) {
|
|
2881
|
+
function $mol_func_name(func) {
|
|
2882
|
+
let name = func.name;
|
|
2883
|
+
if (name?.length > 1)
|
|
2884
|
+
return name;
|
|
2885
|
+
for (let key in this) {
|
|
2886
|
+
try {
|
|
2887
|
+
if (this[key] !== func)
|
|
2888
|
+
continue;
|
|
2889
|
+
name = key;
|
|
2890
|
+
Object.defineProperty(func, 'name', { value: name });
|
|
2891
|
+
break;
|
|
2892
|
+
}
|
|
2893
|
+
catch { }
|
|
2894
|
+
}
|
|
2895
|
+
return name;
|
|
2896
|
+
}
|
|
2897
|
+
$.$mol_func_name = $mol_func_name;
|
|
2898
|
+
function $mol_func_name_from(target, source) {
|
|
2899
|
+
Object.defineProperty(target, 'name', { value: source.name });
|
|
2900
|
+
return target;
|
|
2901
|
+
}
|
|
2902
|
+
$.$mol_func_name_from = $mol_func_name_from;
|
|
2903
|
+
})($ || ($ = {}));
|
|
2904
|
+
//mol/func/name/name.ts
|
|
2905
|
+
;
|
|
2906
|
+
"use strict";
|
|
2907
|
+
var $;
|
|
2806
2908
|
(function ($_1) {
|
|
2807
2909
|
$mol_test({
|
|
2808
2910
|
'Collect deps'() {
|