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/node.test.js
CHANGED
|
@@ -818,7 +818,7 @@ var $;
|
|
|
818
818
|
$.$mol_jsx_frag = '';
|
|
819
819
|
function $mol_jsx(Elem, props, ...childNodes) {
|
|
820
820
|
const id = props && props.id || '';
|
|
821
|
-
const guid = $.$mol_jsx_prefix + id;
|
|
821
|
+
const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
|
|
822
822
|
if (Elem && $.$mol_jsx_booked) {
|
|
823
823
|
if ($.$mol_jsx_booked.has(id)) {
|
|
824
824
|
$mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`));
|
|
@@ -2808,50 +2808,50 @@ var $;
|
|
|
2808
2808
|
const Button = (props, target) => {
|
|
2809
2809
|
return $mol_jsx("button", { title: props.hint }, target());
|
|
2810
2810
|
};
|
|
2811
|
-
const dom = $mol_jsx(Button, { id: "
|
|
2812
|
-
$mol_assert_equal(dom.outerHTML, '<button title="click me" id="
|
|
2811
|
+
const dom = $mol_jsx(Button, { id: "foo", hint: "click me" }, () => 'hey!');
|
|
2812
|
+
$mol_assert_equal(dom.outerHTML, '<button title="click me" id="foo">hey!</button>');
|
|
2813
2813
|
},
|
|
2814
2814
|
'Nested guid generation'() {
|
|
2815
2815
|
const Foo = () => {
|
|
2816
2816
|
return $mol_jsx("div", null,
|
|
2817
|
-
$mol_jsx(Bar, { id: "
|
|
2818
|
-
$mol_jsx("img", { id: "
|
|
2817
|
+
$mol_jsx(Bar, { id: "bar" },
|
|
2818
|
+
$mol_jsx("img", { id: "icon" })));
|
|
2819
2819
|
};
|
|
2820
2820
|
const Bar = (props, icon) => {
|
|
2821
2821
|
return $mol_jsx("span", null, icon);
|
|
2822
2822
|
};
|
|
2823
|
-
const dom = $mol_jsx(Foo, { id: "
|
|
2824
|
-
$mol_assert_equal(dom.outerHTML, '<div id="
|
|
2823
|
+
const dom = $mol_jsx(Foo, { id: "foo" });
|
|
2824
|
+
$mol_assert_equal(dom.outerHTML, '<div id="foo"><span id="foo/bar"><img id="foo/icon"></span></div>');
|
|
2825
2825
|
},
|
|
2826
2826
|
'Fail on non unique ids'() {
|
|
2827
2827
|
const App = () => {
|
|
2828
2828
|
return $mol_jsx("div", null,
|
|
2829
|
-
$mol_jsx("span", { id: "
|
|
2830
|
-
$mol_jsx("span", { id: "
|
|
2829
|
+
$mol_jsx("span", { id: "bar" }),
|
|
2830
|
+
$mol_jsx("span", { id: "bar" }));
|
|
2831
2831
|
};
|
|
2832
|
-
$mol_assert_fail(() => $mol_jsx(App, { id: "
|
|
2832
|
+
$mol_assert_fail(() => $mol_jsx(App, { id: "foo" }), 'JSX already has tag with id "foo/bar"');
|
|
2833
2833
|
},
|
|
2834
2834
|
'Owner based guid generationn'() {
|
|
2835
2835
|
const Foo = () => {
|
|
2836
2836
|
return $mol_jsx("div", null,
|
|
2837
|
-
$mol_jsx(Bar, { id: "
|
|
2837
|
+
$mol_jsx(Bar, { id: "bar", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
|
2838
2838
|
};
|
|
2839
2839
|
const Bar = (props) => {
|
|
2840
2840
|
return $mol_jsx("span", null, props.icon());
|
|
2841
2841
|
};
|
|
2842
|
-
const dom = $mol_jsx(Foo, { id: "
|
|
2843
|
-
$mol_assert_equal(dom.outerHTML, '<div id="
|
|
2842
|
+
const dom = $mol_jsx(Foo, { id: "foo" });
|
|
2843
|
+
$mol_assert_equal(dom.outerHTML, '<div id="foo"><span id="foo/bar"><img id="foo/icon"></span></div>');
|
|
2844
2844
|
},
|
|
2845
2845
|
'Fail on same ids from different caller'() {
|
|
2846
2846
|
const Foo = () => {
|
|
2847
2847
|
return $mol_jsx("div", null,
|
|
2848
|
-
$mol_jsx("img", { id: "
|
|
2849
|
-
$mol_jsx(Bar, { id: "
|
|
2848
|
+
$mol_jsx("img", { id: "icon" }),
|
|
2849
|
+
$mol_jsx(Bar, { id: "bar", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
|
2850
2850
|
};
|
|
2851
2851
|
const Bar = (props) => {
|
|
2852
2852
|
return $mol_jsx("span", null, props.icon());
|
|
2853
2853
|
};
|
|
2854
|
-
$mol_assert_fail(() => $mol_jsx(Foo, { id: "
|
|
2854
|
+
$mol_assert_fail(() => $mol_jsx(Foo, { id: "foo" }), 'JSX already has tag with id "foo/icon"');
|
|
2855
2855
|
},
|
|
2856
2856
|
});
|
|
2857
2857
|
})($ || ($ = {}));
|
|
@@ -2877,9 +2877,9 @@ var $;
|
|
|
2877
2877
|
(function ($) {
|
|
2878
2878
|
$mol_test({
|
|
2879
2879
|
'Attach to document'() {
|
|
2880
|
-
const doc = $mol_dom_parse('<html><body id="
|
|
2881
|
-
$mol_jsx_attach(doc, () => $mol_jsx("body", { id: "
|
|
2882
|
-
$mol_assert_equal(doc.documentElement.outerHTML, '<html><body id="
|
|
2880
|
+
const doc = $mol_dom_parse('<html><body id="foo"></body></html>');
|
|
2881
|
+
$mol_jsx_attach(doc, () => $mol_jsx("body", { id: "foo" }, "bar"));
|
|
2882
|
+
$mol_assert_equal(doc.documentElement.outerHTML, '<html><body id="foo">bar</body></html>');
|
|
2883
2883
|
},
|
|
2884
2884
|
});
|
|
2885
2885
|
})($ || ($ = {}));
|
|
@@ -3865,10 +3865,10 @@ var $;
|
|
|
3865
3865
|
this.childNodes.join('-'));
|
|
3866
3866
|
}
|
|
3867
3867
|
}
|
|
3868
|
-
const dom = $mol_jsx(Foo, { id: "
|
|
3868
|
+
const dom = $mol_jsx(Foo, { id: "foo", title: "bar" },
|
|
3869
3869
|
"xxx",
|
|
3870
3870
|
123);
|
|
3871
|
-
$mol_assert_equal(dom.outerHTML, '<div id="
|
|
3871
|
+
$mol_assert_equal(dom.outerHTML, '<div id="foo">bar xxx-123</div>');
|
|
3872
3872
|
},
|
|
3873
3873
|
'View by element'() {
|
|
3874
3874
|
let br;
|
|
@@ -3876,7 +3876,7 @@ var $;
|
|
|
3876
3876
|
class Br extends $mol_jsx_view {
|
|
3877
3877
|
render() {
|
|
3878
3878
|
br = this;
|
|
3879
|
-
return $mol_jsx("br", { id: "
|
|
3879
|
+
return $mol_jsx("br", { id: "foo" });
|
|
3880
3880
|
}
|
|
3881
3881
|
}
|
|
3882
3882
|
class Brr extends $mol_jsx_view {
|
|
@@ -3889,7 +3889,7 @@ var $;
|
|
|
3889
3889
|
$mol_assert_equal(Brr.of($mol_jsx(Brr, null)), brr);
|
|
3890
3890
|
},
|
|
3891
3891
|
async 'Attached view rerender'() {
|
|
3892
|
-
const doc = $mol_dom_parse('<html><body id="
|
|
3892
|
+
const doc = $mol_dom_parse('<html><body id="foo"></body></html>');
|
|
3893
3893
|
class Title extends $mol_jsx_view {
|
|
3894
3894
|
value(next = 'foo') { return next; }
|
|
3895
3895
|
render() {
|
|
@@ -3899,13 +3899,13 @@ var $;
|
|
|
3899
3899
|
__decorate([
|
|
3900
3900
|
$mol_mem
|
|
3901
3901
|
], Title.prototype, "value", null);
|
|
3902
|
-
const dom = $mol_jsx_attach(doc, () => $mol_jsx(Title, { id: "
|
|
3902
|
+
const dom = $mol_jsx_attach(doc, () => $mol_jsx(Title, { id: "foo" }));
|
|
3903
3903
|
const title = Title.of(dom);
|
|
3904
3904
|
$mol_assert_equal(title.ownerDocument, doc);
|
|
3905
|
-
$mol_assert_equal(doc.documentElement.outerHTML, '<html><body id="
|
|
3905
|
+
$mol_assert_equal(doc.documentElement.outerHTML, '<html><body id="foo">foo</body></html>');
|
|
3906
3906
|
title.value('bar');
|
|
3907
3907
|
await $mol_wire_fiber.sync();
|
|
3908
|
-
$mol_assert_equal(doc.documentElement.outerHTML, '<html><body id="
|
|
3908
|
+
$mol_assert_equal(doc.documentElement.outerHTML, '<html><body id="foo">bar</body></html>');
|
|
3909
3909
|
},
|
|
3910
3910
|
async 'Nested bound views'($) {
|
|
3911
3911
|
class Task extends $mol_jsx_view {
|
|
@@ -3925,23 +3925,23 @@ var $;
|
|
|
3925
3925
|
class App extends $mol_jsx_view {
|
|
3926
3926
|
title(next = '') { return next; }
|
|
3927
3927
|
render() {
|
|
3928
|
-
return ($mol_jsx(List, null, this.title() && $mol_jsx(Task, { id: "
|
|
3928
|
+
return ($mol_jsx(List, null, this.title() && $mol_jsx(Task, { id: "task", title: next => this.title(next) })));
|
|
3929
3929
|
}
|
|
3930
3930
|
}
|
|
3931
3931
|
__decorate([
|
|
3932
3932
|
$mol_mem
|
|
3933
3933
|
], App.prototype, "title", null);
|
|
3934
|
-
const doc = $mol_dom_parse('<html xmlns="http://www.w3.org/1999/xhtml"><body id="
|
|
3935
|
-
const root = $.$mol_jsx_attach(doc, () => $mol_jsx(App, { "$": $, id: "
|
|
3936
|
-
$mol_assert_equal($mol_dom_serialize(doc.documentElement), '<html xmlns="http://www.w3.org/1999/xhtml"><body id="
|
|
3934
|
+
const doc = $mol_dom_parse('<html xmlns="http://www.w3.org/1999/xhtml"><body id="root"></body></html>');
|
|
3935
|
+
const root = $.$mol_jsx_attach(doc, () => $mol_jsx(App, { "$": $, id: "root" }));
|
|
3936
|
+
$mol_assert_equal($mol_dom_serialize(doc.documentElement), '<html xmlns="http://www.w3.org/1999/xhtml"><body id="root" class="list"></body></html>');
|
|
3937
3937
|
App.of(root).title('barbar');
|
|
3938
3938
|
await $mol_wire_fiber.sync();
|
|
3939
3939
|
$mol_assert_equal(Task.of(root.firstElementChild).title(), 'barbar');
|
|
3940
|
-
$mol_assert_equal(doc.documentElement.outerHTML, '<html xmlns="http://www.w3.org/1999/xhtml"><body id="
|
|
3940
|
+
$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>');
|
|
3941
3941
|
Task.of(root.firstElementChild).title('foofoo');
|
|
3942
3942
|
await $mol_wire_fiber.sync();
|
|
3943
3943
|
$mol_assert_equal(App.of(root).title(), 'foofoo');
|
|
3944
|
-
$mol_assert_equal(doc.documentElement.outerHTML, '<html xmlns="http://www.w3.org/1999/xhtml"><body id="
|
|
3944
|
+
$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>');
|
|
3945
3945
|
},
|
|
3946
3946
|
});
|
|
3947
3947
|
})($ || ($ = {}));
|