mol_jsx_lib 0.0.56 → 0.0.59

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/web.test.js CHANGED
@@ -238,6 +238,20 @@ var $;
238
238
  //mol/assert/assert.ts
239
239
  ;
240
240
  "use strict";
241
+ var $;
242
+ (function ($_1) {
243
+ $mol_test({
244
+ 'FQN of anon function'($) {
245
+ const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
246
+ $mol_assert_equal($$.$mol_func_name_test.name, '');
247
+ $mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
248
+ $mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
249
+ },
250
+ });
251
+ })($ || ($ = {}));
252
+ //mol/func/name/name.test.ts
253
+ ;
254
+ "use strict";
241
255
  //mol/type/error/error.ts
242
256
  ;
243
257
  "use strict";
@@ -311,28 +325,50 @@ var $;
311
325
  const Button = (props, target) => {
312
326
  return $mol_jsx("button", { title: props.hint }, target());
313
327
  };
314
- const dom = $mol_jsx(Button, { id: "/foo", hint: "click me" }, () => 'hey!');
315
- $mol_assert_equal(dom.outerHTML, '<button title="click me" id="/foo">hey!</button>');
328
+ const dom = $mol_jsx(Button, { id: "foo", hint: "click me" }, () => 'hey!');
329
+ $mol_assert_equal(dom.outerHTML, '<button title="click me" id="foo" class="Button">hey!</button>');
316
330
  },
317
331
  'Nested guid generation'() {
318
332
  const Foo = () => {
319
333
  return $mol_jsx("div", null,
320
- $mol_jsx(Bar, { id: "/bar" },
321
- $mol_jsx("img", { id: "/icon" })));
334
+ $mol_jsx(Bar, { id: "bar" },
335
+ $mol_jsx("img", { id: "icon" })));
322
336
  };
323
337
  const Bar = (props, icon) => {
324
338
  return $mol_jsx("span", null, icon);
325
339
  };
326
- const dom = $mol_jsx(Foo, { id: "/foo" });
327
- $mol_assert_equal(dom.outerHTML, '<div id="/foo"><span id="/foo/bar"><img id="/foo/icon"></span></div>');
340
+ const dom = $mol_jsx(Foo, { id: "foo" });
341
+ $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"></span></div>');
328
342
  },
329
343
  'Fail on non unique ids'() {
330
344
  const App = () => {
331
345
  return $mol_jsx("div", null,
332
- $mol_jsx("span", { id: "/bar" }),
333
- $mol_jsx("span", { id: "/bar" }));
346
+ $mol_jsx("span", { id: "bar" }),
347
+ $mol_jsx("span", { id: "bar" }));
348
+ };
349
+ $mol_assert_fail(() => $mol_jsx(App, { id: "foo" }), 'JSX already has tag with id "foo/bar"');
350
+ },
351
+ 'Owner based guid generationn'() {
352
+ const Foo = () => {
353
+ return $mol_jsx("div", null,
354
+ $mol_jsx(Bar, { id: "middle", icon: () => $mol_jsx("img", { id: "icon" }) }));
355
+ };
356
+ const Bar = (props) => {
357
+ return $mol_jsx("span", null, props.icon());
358
+ };
359
+ const dom = $mol_jsx(Foo, { id: "app" });
360
+ $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>');
361
+ },
362
+ 'Fail on same ids from different caller'() {
363
+ const Foo = () => {
364
+ return $mol_jsx("div", null,
365
+ $mol_jsx("img", { id: "icon" }),
366
+ $mol_jsx(Bar, { id: "bar", icon: () => $mol_jsx("img", { id: "icon" }) }));
367
+ };
368
+ const Bar = (props) => {
369
+ return $mol_jsx("span", null, props.icon());
334
370
  };
335
- $mol_assert_fail(() => $mol_jsx(App, { id: "/foo" }), 'JSX already has tag with id "/bar"');
371
+ $mol_assert_fail(() => $mol_jsx(Foo, { id: "foo" }), 'JSX already has tag with id "foo/icon"');
336
372
  },
337
373
  });
338
374
  })($ || ($ = {}));
@@ -358,9 +394,9 @@ var $;
358
394
  (function ($) {
359
395
  $mol_test({
360
396
  'Attach to document'() {
361
- const doc = $mol_dom_parse('<html><body id="/foo"></body></html>');
362
- $mol_jsx_attach(doc, () => $mol_jsx("body", { id: "/foo" }, "bar"));
363
- $mol_assert_equal(doc.documentElement.outerHTML, '<html><body id="/foo">bar</body></html>');
397
+ const doc = $mol_dom_parse('<html><body id="foo"></body></html>');
398
+ $mol_jsx_attach(doc, () => $mol_jsx("body", { id: "foo" }, "bar"));
399
+ $mol_assert_equal(doc.documentElement.outerHTML, '<html><body id="foo">bar</body></html>');
364
400
  },
365
401
  });
366
402
  })($ || ($ = {}));
@@ -1412,10 +1448,10 @@ var $;
1412
1448
  this.childNodes.join('-'));
1413
1449
  }
1414
1450
  }
1415
- const dom = $mol_jsx(Foo, { id: "/foo", title: "bar" },
1451
+ const dom = $mol_jsx(Foo, { id: "foo", title: "bar" },
1416
1452
  "xxx",
1417
1453
  123);
1418
- $mol_assert_equal(dom.outerHTML, '<div id="/foo">bar xxx-123</div>');
1454
+ $mol_assert_equal(dom.outerHTML, '<div id="foo" class="Foo">bar xxx-123</div>');
1419
1455
  },
1420
1456
  'View by element'() {
1421
1457
  let br;
@@ -1423,7 +1459,7 @@ var $;
1423
1459
  class Br extends $mol_jsx_view {
1424
1460
  render() {
1425
1461
  br = this;
1426
- return $mol_jsx("br", { id: "/foo" });
1462
+ return $mol_jsx("br", { id: "foo" });
1427
1463
  }
1428
1464
  }
1429
1465
  class Brr extends $mol_jsx_view {
@@ -1436,7 +1472,7 @@ var $;
1436
1472
  $mol_assert_equal(Brr.of($mol_jsx(Brr, null)), brr);
1437
1473
  },
1438
1474
  async 'Attached view rerender'() {
1439
- const doc = $mol_dom_parse('<html><body id="/foo"></body></html>');
1475
+ const doc = $mol_dom_parse('<html><body id="foo"></body></html>');
1440
1476
  class Title extends $mol_jsx_view {
1441
1477
  value(next = 'foo') { return next; }
1442
1478
  render() {
@@ -1446,13 +1482,13 @@ var $;
1446
1482
  __decorate([
1447
1483
  $mol_mem
1448
1484
  ], Title.prototype, "value", null);
1449
- const dom = $mol_jsx_attach(doc, () => $mol_jsx(Title, { id: "/foo" }));
1485
+ const dom = $mol_jsx_attach(doc, () => $mol_jsx(Title, { id: "foo" }));
1450
1486
  const title = Title.of(dom);
1451
1487
  $mol_assert_equal(title.ownerDocument, doc);
1452
- $mol_assert_equal(doc.documentElement.outerHTML, '<html><body id="/foo">foo</body></html>');
1488
+ $mol_assert_equal(doc.documentElement.outerHTML, '<html><body id="foo" class="Title">foo</body></html>');
1453
1489
  title.value('bar');
1454
1490
  await $mol_wire_fiber.sync();
1455
- $mol_assert_equal(doc.documentElement.outerHTML, '<html><body id="/foo">bar</body></html>');
1491
+ $mol_assert_equal(doc.documentElement.outerHTML, '<html><body id="foo" class="Title">bar</body></html>');
1456
1492
  },
1457
1493
  async 'Nested bound views'($) {
1458
1494
  class Task extends $mol_jsx_view {
@@ -1472,23 +1508,23 @@ var $;
1472
1508
  class App extends $mol_jsx_view {
1473
1509
  title(next = '') { return next; }
1474
1510
  render() {
1475
- return ($mol_jsx(List, null, this.title() && $mol_jsx(Task, { id: "/task", title: next => this.title(next) })));
1511
+ return ($mol_jsx(List, null, this.title() && $mol_jsx(Task, { id: "task", title: next => this.title(next) })));
1476
1512
  }
1477
1513
  }
1478
1514
  __decorate([
1479
1515
  $mol_mem
1480
1516
  ], App.prototype, "title", null);
1481
- const doc = $mol_dom_parse('<html xmlns="http://www.w3.org/1999/xhtml"><body id="/root"></body></html>');
1482
- const root = $.$mol_jsx_attach(doc, () => $mol_jsx(App, { "$": $, id: "/root" }));
1483
- $mol_assert_equal($mol_dom_serialize(doc.documentElement), '<html xmlns="http://www.w3.org/1999/xhtml"><body id="/root" class="list"></body></html>');
1517
+ const doc = $mol_dom_parse('<html xmlns="http://www.w3.org/1999/xhtml"><body id="root"></body></html>');
1518
+ const root = $.$mol_jsx_attach(doc, () => $mol_jsx(App, { "$": $, id: "root" }));
1519
+ $mol_assert_equal($mol_dom_serialize(doc.documentElement), '<html xmlns="http://www.w3.org/1999/xhtml"><body id="root" class="list App List"></body></html>');
1484
1520
  App.of(root).title('barbar');
1485
1521
  await $mol_wire_fiber.sync();
1486
1522
  $mol_assert_equal(Task.of(root.firstElementChild).title(), 'barbar');
1487
- $mol_assert_equal(doc.documentElement.outerHTML, '<html xmlns="http://www.w3.org/1999/xhtml"><body id="/root" class="list"><h1 id="/root/task">barbar</h1></body></html>');
1523
+ $mol_assert_equal(doc.documentElement.outerHTML, '<html xmlns="http://www.w3.org/1999/xhtml"><body id="root" class="list App List"><h1 id="root/task" class="App_task Task">barbar</h1></body></html>');
1488
1524
  Task.of(root.firstElementChild).title('foofoo');
1489
1525
  await $mol_wire_fiber.sync();
1490
1526
  $mol_assert_equal(App.of(root).title(), 'foofoo');
1491
- $mol_assert_equal(doc.documentElement.outerHTML, '<html xmlns="http://www.w3.org/1999/xhtml"><body id="/root" class="list"><h1 id="/root/task">foofoo</h1></body></html>');
1527
+ $mol_assert_equal(doc.documentElement.outerHTML, '<html xmlns="http://www.w3.org/1999/xhtml"><body id="root" class="list App List"><h1 id="root/task" class="App_task Task">foofoo</h1></body></html>');
1492
1528
  },
1493
1529
  });
1494
1530
  })($ || ($ = {}));