mol_data_all 1.1.356 → 1.1.359
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/package.json
CHANGED
package/web.test.js
CHANGED
|
@@ -225,28 +225,52 @@ var $;
|
|
|
225
225
|
const Button = (props, target) => {
|
|
226
226
|
return $mol_jsx("button", { title: props.hint }, target());
|
|
227
227
|
};
|
|
228
|
-
const dom = $mol_jsx(Button, { id: "
|
|
229
|
-
$mol_assert_equal(dom.outerHTML, '<button title="click me" id="
|
|
228
|
+
const dom = $mol_jsx(Button, { id: "foo", hint: "click me" }, () => 'hey!');
|
|
229
|
+
$mol_assert_equal(dom.outerHTML, '<button title="click me" id="foo" class="Button">hey!</button>');
|
|
230
230
|
},
|
|
231
231
|
'Nested guid generation'() {
|
|
232
232
|
const Foo = () => {
|
|
233
233
|
return $mol_jsx("div", null,
|
|
234
|
-
$mol_jsx(Bar, { id: "
|
|
235
|
-
$mol_jsx("img", { id: "
|
|
234
|
+
$mol_jsx(Bar, { id: "bar" },
|
|
235
|
+
$mol_jsx("img", { id: "icon" })));
|
|
236
236
|
};
|
|
237
237
|
const Bar = (props, icon) => {
|
|
238
|
-
return $mol_jsx("span", null,
|
|
238
|
+
return $mol_jsx("span", null,
|
|
239
|
+
icon,
|
|
240
|
+
$mol_jsx("i", { id: "label" }));
|
|
239
241
|
};
|
|
240
|
-
const dom = $mol_jsx(Foo, { id: "
|
|
241
|
-
$mol_assert_equal(dom.outerHTML, '<div id="
|
|
242
|
+
const dom = $mol_jsx(Foo, { id: "foo" });
|
|
243
|
+
$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>');
|
|
242
244
|
},
|
|
243
245
|
'Fail on non unique ids'() {
|
|
244
246
|
const App = () => {
|
|
245
247
|
return $mol_jsx("div", null,
|
|
246
|
-
$mol_jsx("span", { id: "
|
|
247
|
-
$mol_jsx("span", { id: "
|
|
248
|
+
$mol_jsx("span", { id: "bar" }),
|
|
249
|
+
$mol_jsx("span", { id: "bar" }));
|
|
248
250
|
};
|
|
249
|
-
$mol_assert_fail(() => $mol_jsx(App, { id: "
|
|
251
|
+
$mol_assert_fail(() => $mol_jsx(App, { id: "foo" }), 'JSX already has tag with id "foo/bar"');
|
|
252
|
+
},
|
|
253
|
+
'Owner based guid generationn'() {
|
|
254
|
+
const Foo = () => {
|
|
255
|
+
return $mol_jsx("div", null,
|
|
256
|
+
$mol_jsx(Bar, { id: "middle", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
|
257
|
+
};
|
|
258
|
+
const Bar = (props) => {
|
|
259
|
+
return $mol_jsx("span", null, props.icon());
|
|
260
|
+
};
|
|
261
|
+
const dom = $mol_jsx(Foo, { id: "app" });
|
|
262
|
+
$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>');
|
|
263
|
+
},
|
|
264
|
+
'Fail on same ids from different caller'() {
|
|
265
|
+
const Foo = () => {
|
|
266
|
+
return $mol_jsx("div", null,
|
|
267
|
+
$mol_jsx("img", { id: "icon" }),
|
|
268
|
+
$mol_jsx(Bar, { id: "bar", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
|
269
|
+
};
|
|
270
|
+
const Bar = (props) => {
|
|
271
|
+
return $mol_jsx("span", null, props.icon());
|
|
272
|
+
};
|
|
273
|
+
$mol_assert_fail(() => $mol_jsx(Foo, { id: "foo" }), 'JSX already has tag with id "foo/icon"');
|
|
250
274
|
},
|
|
251
275
|
});
|
|
252
276
|
})($ || ($ = {}));
|
|
@@ -256,6 +280,7 @@ var $;
|
|
|
256
280
|
var $;
|
|
257
281
|
(function ($) {
|
|
258
282
|
$.$mol_jsx_prefix = '';
|
|
283
|
+
$.$mol_jsx_crumbs = '';
|
|
259
284
|
$.$mol_jsx_booked = null;
|
|
260
285
|
$.$mol_jsx_document = {
|
|
261
286
|
getElementById: () => null,
|
|
@@ -265,16 +290,45 @@ var $;
|
|
|
265
290
|
$.$mol_jsx_frag = '';
|
|
266
291
|
function $mol_jsx(Elem, props, ...childNodes) {
|
|
267
292
|
const id = props && props.id || '';
|
|
293
|
+
const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
|
|
294
|
+
const crumbs_self = id ? $.$mol_jsx_crumbs.replace(/(\S+)/g, `$1_${id}`) : $.$mol_jsx_crumbs;
|
|
268
295
|
if (Elem && $.$mol_jsx_booked) {
|
|
269
296
|
if ($.$mol_jsx_booked.has(id)) {
|
|
270
|
-
$mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(
|
|
297
|
+
$mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`));
|
|
271
298
|
}
|
|
272
299
|
else {
|
|
273
300
|
$.$mol_jsx_booked.add(id);
|
|
274
301
|
}
|
|
275
302
|
}
|
|
276
|
-
const guid = $.$mol_jsx_prefix + id;
|
|
277
303
|
let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
|
|
304
|
+
if ($.$mol_jsx_prefix) {
|
|
305
|
+
const prefix_ext = $.$mol_jsx_prefix;
|
|
306
|
+
const booked_ext = $.$mol_jsx_booked;
|
|
307
|
+
const crumbs_ext = $.$mol_jsx_crumbs;
|
|
308
|
+
for (const field in props) {
|
|
309
|
+
const func = props[field];
|
|
310
|
+
if (typeof func !== 'function')
|
|
311
|
+
continue;
|
|
312
|
+
const wrapper = function (...args) {
|
|
313
|
+
const prefix = $.$mol_jsx_prefix;
|
|
314
|
+
const booked = $.$mol_jsx_booked;
|
|
315
|
+
const crumbs = $.$mol_jsx_crumbs;
|
|
316
|
+
try {
|
|
317
|
+
$.$mol_jsx_prefix = prefix_ext;
|
|
318
|
+
$.$mol_jsx_booked = booked_ext;
|
|
319
|
+
$.$mol_jsx_crumbs = crumbs_ext;
|
|
320
|
+
return func.call(this, ...args);
|
|
321
|
+
}
|
|
322
|
+
finally {
|
|
323
|
+
$.$mol_jsx_prefix = prefix;
|
|
324
|
+
$.$mol_jsx_booked = booked;
|
|
325
|
+
$.$mol_jsx_crumbs = crumbs;
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
$mol_func_name_from(wrapper, func);
|
|
329
|
+
props[field] = wrapper;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
278
332
|
if (typeof Elem !== 'string') {
|
|
279
333
|
if ('prototype' in Elem) {
|
|
280
334
|
const view = node && node[Elem] || new Elem;
|
|
@@ -283,6 +337,7 @@ var $;
|
|
|
283
337
|
view.childNodes = childNodes;
|
|
284
338
|
if (!view.ownerDocument)
|
|
285
339
|
view.ownerDocument = $.$mol_jsx_document;
|
|
340
|
+
view.className = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
|
|
286
341
|
node = view.valueOf();
|
|
287
342
|
node[Elem] = view;
|
|
288
343
|
return node;
|
|
@@ -290,14 +345,17 @@ var $;
|
|
|
290
345
|
else {
|
|
291
346
|
const prefix = $.$mol_jsx_prefix;
|
|
292
347
|
const booked = $.$mol_jsx_booked;
|
|
348
|
+
const crumbs = $.$mol_jsx_crumbs;
|
|
293
349
|
try {
|
|
294
350
|
$.$mol_jsx_prefix = guid;
|
|
295
351
|
$.$mol_jsx_booked = new Set;
|
|
352
|
+
$.$mol_jsx_crumbs = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
|
|
296
353
|
return Elem(props, ...childNodes);
|
|
297
354
|
}
|
|
298
355
|
finally {
|
|
299
356
|
$.$mol_jsx_prefix = prefix;
|
|
300
357
|
$.$mol_jsx_booked = booked;
|
|
358
|
+
$.$mol_jsx_crumbs = crumbs;
|
|
301
359
|
}
|
|
302
360
|
}
|
|
303
361
|
}
|
|
@@ -328,6 +386,8 @@ var $;
|
|
|
328
386
|
}
|
|
329
387
|
if (guid)
|
|
330
388
|
node.id = guid;
|
|
389
|
+
if ($.$mol_jsx_crumbs)
|
|
390
|
+
node.className = (props?.['class'] ? props['class'] + ' ' : '') + crumbs_self;
|
|
331
391
|
return node;
|
|
332
392
|
}
|
|
333
393
|
$.$mol_jsx = $mol_jsx;
|
|
@@ -729,6 +789,48 @@ var $;
|
|
|
729
789
|
;
|
|
730
790
|
"use strict";
|
|
731
791
|
var $;
|
|
792
|
+
(function ($_1) {
|
|
793
|
+
$mol_test({
|
|
794
|
+
'FQN of anon function'($) {
|
|
795
|
+
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
796
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
797
|
+
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
798
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
799
|
+
},
|
|
800
|
+
});
|
|
801
|
+
})($ || ($ = {}));
|
|
802
|
+
//mol/func/name/name.test.ts
|
|
803
|
+
;
|
|
804
|
+
"use strict";
|
|
805
|
+
var $;
|
|
806
|
+
(function ($) {
|
|
807
|
+
function $mol_func_name(func) {
|
|
808
|
+
let name = func.name;
|
|
809
|
+
if (name?.length > 1)
|
|
810
|
+
return name;
|
|
811
|
+
for (let key in this) {
|
|
812
|
+
try {
|
|
813
|
+
if (this[key] !== func)
|
|
814
|
+
continue;
|
|
815
|
+
name = key;
|
|
816
|
+
Object.defineProperty(func, 'name', { value: name });
|
|
817
|
+
break;
|
|
818
|
+
}
|
|
819
|
+
catch { }
|
|
820
|
+
}
|
|
821
|
+
return name;
|
|
822
|
+
}
|
|
823
|
+
$.$mol_func_name = $mol_func_name;
|
|
824
|
+
function $mol_func_name_from(target, source) {
|
|
825
|
+
Object.defineProperty(target, 'name', { value: source.name });
|
|
826
|
+
return target;
|
|
827
|
+
}
|
|
828
|
+
$.$mol_func_name_from = $mol_func_name_from;
|
|
829
|
+
})($ || ($ = {}));
|
|
830
|
+
//mol/func/name/name.ts
|
|
831
|
+
;
|
|
832
|
+
"use strict";
|
|
833
|
+
var $;
|
|
732
834
|
(function ($) {
|
|
733
835
|
$mol_test({
|
|
734
836
|
'Is number'() {
|