mol_jsx_lib 0.0.57 → 0.0.58
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.esm.js +1 -1
- package/node.esm.js.map +1 -1
- package/node.js +1 -1
- package/node.js.map +1 -1
- package/node.test.js +32 -32
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.esm.js +1 -1
- package/web.esm.js.map +1 -1
- package/web.js +1 -1
- package/web.js.map +1 -1
- package/web.test.js +31 -31
- package/web.test.js.map +1 -1
package/web.test.js
CHANGED
|
@@ -325,50 +325,50 @@ var $;
|
|
|
325
325
|
const Button = (props, target) => {
|
|
326
326
|
return $mol_jsx("button", { title: props.hint }, target());
|
|
327
327
|
};
|
|
328
|
-
const dom = $mol_jsx(Button, { id: "
|
|
329
|
-
$mol_assert_equal(dom.outerHTML, '<button title="click me" id="
|
|
328
|
+
const dom = $mol_jsx(Button, { id: "foo", hint: "click me" }, () => 'hey!');
|
|
329
|
+
$mol_assert_equal(dom.outerHTML, '<button title="click me" id="foo">hey!</button>');
|
|
330
330
|
},
|
|
331
331
|
'Nested guid generation'() {
|
|
332
332
|
const Foo = () => {
|
|
333
333
|
return $mol_jsx("div", null,
|
|
334
|
-
$mol_jsx(Bar, { id: "
|
|
335
|
-
$mol_jsx("img", { id: "
|
|
334
|
+
$mol_jsx(Bar, { id: "bar" },
|
|
335
|
+
$mol_jsx("img", { id: "icon" })));
|
|
336
336
|
};
|
|
337
337
|
const Bar = (props, icon) => {
|
|
338
338
|
return $mol_jsx("span", null, icon);
|
|
339
339
|
};
|
|
340
|
-
const dom = $mol_jsx(Foo, { id: "
|
|
341
|
-
$mol_assert_equal(dom.outerHTML, '<div id="
|
|
340
|
+
const dom = $mol_jsx(Foo, { id: "foo" });
|
|
341
|
+
$mol_assert_equal(dom.outerHTML, '<div id="foo"><span id="foo/bar"><img id="foo/icon"></span></div>');
|
|
342
342
|
},
|
|
343
343
|
'Fail on non unique ids'() {
|
|
344
344
|
const App = () => {
|
|
345
345
|
return $mol_jsx("div", null,
|
|
346
|
-
$mol_jsx("span", { id: "
|
|
347
|
-
$mol_jsx("span", { id: "
|
|
346
|
+
$mol_jsx("span", { id: "bar" }),
|
|
347
|
+
$mol_jsx("span", { id: "bar" }));
|
|
348
348
|
};
|
|
349
|
-
$mol_assert_fail(() => $mol_jsx(App, { id: "
|
|
349
|
+
$mol_assert_fail(() => $mol_jsx(App, { id: "foo" }), 'JSX already has tag with id "foo/bar"');
|
|
350
350
|
},
|
|
351
351
|
'Owner based guid generationn'() {
|
|
352
352
|
const Foo = () => {
|
|
353
353
|
return $mol_jsx("div", null,
|
|
354
|
-
$mol_jsx(Bar, { id: "
|
|
354
|
+
$mol_jsx(Bar, { id: "bar", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
|
355
355
|
};
|
|
356
356
|
const Bar = (props) => {
|
|
357
357
|
return $mol_jsx("span", null, props.icon());
|
|
358
358
|
};
|
|
359
|
-
const dom = $mol_jsx(Foo, { id: "
|
|
360
|
-
$mol_assert_equal(dom.outerHTML, '<div id="
|
|
359
|
+
const dom = $mol_jsx(Foo, { id: "foo" });
|
|
360
|
+
$mol_assert_equal(dom.outerHTML, '<div id="foo"><span id="foo/bar"><img id="foo/icon"></span></div>');
|
|
361
361
|
},
|
|
362
362
|
'Fail on same ids from different caller'() {
|
|
363
363
|
const Foo = () => {
|
|
364
364
|
return $mol_jsx("div", null,
|
|
365
|
-
$mol_jsx("img", { id: "
|
|
366
|
-
$mol_jsx(Bar, { id: "
|
|
365
|
+
$mol_jsx("img", { id: "icon" }),
|
|
366
|
+
$mol_jsx(Bar, { id: "bar", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
|
367
367
|
};
|
|
368
368
|
const Bar = (props) => {
|
|
369
369
|
return $mol_jsx("span", null, props.icon());
|
|
370
370
|
};
|
|
371
|
-
$mol_assert_fail(() => $mol_jsx(Foo, { id: "
|
|
371
|
+
$mol_assert_fail(() => $mol_jsx(Foo, { id: "foo" }), 'JSX already has tag with id "foo/icon"');
|
|
372
372
|
},
|
|
373
373
|
});
|
|
374
374
|
})($ || ($ = {}));
|
|
@@ -394,9 +394,9 @@ var $;
|
|
|
394
394
|
(function ($) {
|
|
395
395
|
$mol_test({
|
|
396
396
|
'Attach to document'() {
|
|
397
|
-
const doc = $mol_dom_parse('<html><body id="
|
|
398
|
-
$mol_jsx_attach(doc, () => $mol_jsx("body", { id: "
|
|
399
|
-
$mol_assert_equal(doc.documentElement.outerHTML, '<html><body id="
|
|
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>');
|
|
400
400
|
},
|
|
401
401
|
});
|
|
402
402
|
})($ || ($ = {}));
|
|
@@ -1448,10 +1448,10 @@ var $;
|
|
|
1448
1448
|
this.childNodes.join('-'));
|
|
1449
1449
|
}
|
|
1450
1450
|
}
|
|
1451
|
-
const dom = $mol_jsx(Foo, { id: "
|
|
1451
|
+
const dom = $mol_jsx(Foo, { id: "foo", title: "bar" },
|
|
1452
1452
|
"xxx",
|
|
1453
1453
|
123);
|
|
1454
|
-
$mol_assert_equal(dom.outerHTML, '<div id="
|
|
1454
|
+
$mol_assert_equal(dom.outerHTML, '<div id="foo">bar xxx-123</div>');
|
|
1455
1455
|
},
|
|
1456
1456
|
'View by element'() {
|
|
1457
1457
|
let br;
|
|
@@ -1459,7 +1459,7 @@ var $;
|
|
|
1459
1459
|
class Br extends $mol_jsx_view {
|
|
1460
1460
|
render() {
|
|
1461
1461
|
br = this;
|
|
1462
|
-
return $mol_jsx("br", { id: "
|
|
1462
|
+
return $mol_jsx("br", { id: "foo" });
|
|
1463
1463
|
}
|
|
1464
1464
|
}
|
|
1465
1465
|
class Brr extends $mol_jsx_view {
|
|
@@ -1472,7 +1472,7 @@ var $;
|
|
|
1472
1472
|
$mol_assert_equal(Brr.of($mol_jsx(Brr, null)), brr);
|
|
1473
1473
|
},
|
|
1474
1474
|
async 'Attached view rerender'() {
|
|
1475
|
-
const doc = $mol_dom_parse('<html><body id="
|
|
1475
|
+
const doc = $mol_dom_parse('<html><body id="foo"></body></html>');
|
|
1476
1476
|
class Title extends $mol_jsx_view {
|
|
1477
1477
|
value(next = 'foo') { return next; }
|
|
1478
1478
|
render() {
|
|
@@ -1482,13 +1482,13 @@ var $;
|
|
|
1482
1482
|
__decorate([
|
|
1483
1483
|
$mol_mem
|
|
1484
1484
|
], Title.prototype, "value", null);
|
|
1485
|
-
const dom = $mol_jsx_attach(doc, () => $mol_jsx(Title, { id: "
|
|
1485
|
+
const dom = $mol_jsx_attach(doc, () => $mol_jsx(Title, { id: "foo" }));
|
|
1486
1486
|
const title = Title.of(dom);
|
|
1487
1487
|
$mol_assert_equal(title.ownerDocument, doc);
|
|
1488
|
-
$mol_assert_equal(doc.documentElement.outerHTML, '<html><body id="
|
|
1488
|
+
$mol_assert_equal(doc.documentElement.outerHTML, '<html><body id="foo">foo</body></html>');
|
|
1489
1489
|
title.value('bar');
|
|
1490
1490
|
await $mol_wire_fiber.sync();
|
|
1491
|
-
$mol_assert_equal(doc.documentElement.outerHTML, '<html><body id="
|
|
1491
|
+
$mol_assert_equal(doc.documentElement.outerHTML, '<html><body id="foo">bar</body></html>');
|
|
1492
1492
|
},
|
|
1493
1493
|
async 'Nested bound views'($) {
|
|
1494
1494
|
class Task extends $mol_jsx_view {
|
|
@@ -1508,23 +1508,23 @@ var $;
|
|
|
1508
1508
|
class App extends $mol_jsx_view {
|
|
1509
1509
|
title(next = '') { return next; }
|
|
1510
1510
|
render() {
|
|
1511
|
-
return ($mol_jsx(List, null, this.title() && $mol_jsx(Task, { id: "
|
|
1511
|
+
return ($mol_jsx(List, null, this.title() && $mol_jsx(Task, { id: "task", title: next => this.title(next) })));
|
|
1512
1512
|
}
|
|
1513
1513
|
}
|
|
1514
1514
|
__decorate([
|
|
1515
1515
|
$mol_mem
|
|
1516
1516
|
], App.prototype, "title", null);
|
|
1517
|
-
const doc = $mol_dom_parse('<html xmlns="http://www.w3.org/1999/xhtml"><body id="
|
|
1518
|
-
const root = $.$mol_jsx_attach(doc, () => $mol_jsx(App, { "$": $, id: "
|
|
1519
|
-
$mol_assert_equal($mol_dom_serialize(doc.documentElement), '<html xmlns="http://www.w3.org/1999/xhtml"><body id="
|
|
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"></body></html>');
|
|
1520
1520
|
App.of(root).title('barbar');
|
|
1521
1521
|
await $mol_wire_fiber.sync();
|
|
1522
1522
|
$mol_assert_equal(Task.of(root.firstElementChild).title(), 'barbar');
|
|
1523
|
-
$mol_assert_equal(doc.documentElement.outerHTML, '<html xmlns="http://www.w3.org/1999/xhtml"><body id="
|
|
1523
|
+
$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>');
|
|
1524
1524
|
Task.of(root.firstElementChild).title('foofoo');
|
|
1525
1525
|
await $mol_wire_fiber.sync();
|
|
1526
1526
|
$mol_assert_equal(App.of(root).title(), 'foofoo');
|
|
1527
|
-
$mol_assert_equal(doc.documentElement.outerHTML, '<html xmlns="http://www.w3.org/1999/xhtml"><body id="
|
|
1527
|
+
$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>');
|
|
1528
1528
|
},
|
|
1529
1529
|
});
|
|
1530
1530
|
})($ || ($ = {}));
|