mol_jsx_lib 0.0.58 → 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/node.d.ts +2 -0
- package/node.deps.json +1 -1
- package/node.esm.js +16 -0
- package/node.esm.js.map +1 -1
- package/node.js +16 -0
- package/node.js.map +1 -1
- package/node.test.js +27 -11
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.d.ts +2 -0
- package/web.deps.json +1 -1
- package/web.esm.js +16 -0
- package/web.esm.js.map +1 -1
- package/web.js +16 -0
- package/web.js.map +1 -1
- package/web.test.js +11 -11
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -809,6 +809,7 @@ var $;
|
|
|
809
809
|
var $;
|
|
810
810
|
(function ($) {
|
|
811
811
|
$.$mol_jsx_prefix = '';
|
|
812
|
+
$.$mol_jsx_crumbs = '';
|
|
812
813
|
$.$mol_jsx_booked = null;
|
|
813
814
|
$.$mol_jsx_document = {
|
|
814
815
|
getElementById: () => null,
|
|
@@ -819,6 +820,7 @@ var $;
|
|
|
819
820
|
function $mol_jsx(Elem, props, ...childNodes) {
|
|
820
821
|
const id = props && props.id || '';
|
|
821
822
|
const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
|
|
823
|
+
const crumbs_self = id ? $.$mol_jsx_crumbs.replace(/([^ ]+)/, `$1_${id}`) : $.$mol_jsx_crumbs;
|
|
822
824
|
if (Elem && $.$mol_jsx_booked) {
|
|
823
825
|
if ($.$mol_jsx_booked.has(id)) {
|
|
824
826
|
$mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`));
|
|
@@ -831,6 +833,7 @@ var $;
|
|
|
831
833
|
if ($.$mol_jsx_prefix) {
|
|
832
834
|
const prefix_ext = $.$mol_jsx_prefix;
|
|
833
835
|
const booked_ext = $.$mol_jsx_booked;
|
|
836
|
+
const crumbs_ext = $.$mol_jsx_crumbs;
|
|
834
837
|
for (const field in props) {
|
|
835
838
|
const func = props[field];
|
|
836
839
|
if (typeof func !== 'function')
|
|
@@ -838,14 +841,17 @@ var $;
|
|
|
838
841
|
const wrapper = function (...args) {
|
|
839
842
|
const prefix = $.$mol_jsx_prefix;
|
|
840
843
|
const booked = $.$mol_jsx_booked;
|
|
844
|
+
const crumbs = $.$mol_jsx_crumbs;
|
|
841
845
|
try {
|
|
842
846
|
$.$mol_jsx_prefix = prefix_ext;
|
|
843
847
|
$.$mol_jsx_booked = booked_ext;
|
|
848
|
+
$.$mol_jsx_crumbs = crumbs_ext;
|
|
844
849
|
return func.call(this, ...args);
|
|
845
850
|
}
|
|
846
851
|
finally {
|
|
847
852
|
$.$mol_jsx_prefix = prefix;
|
|
848
853
|
$.$mol_jsx_booked = booked;
|
|
854
|
+
$.$mol_jsx_crumbs = crumbs;
|
|
849
855
|
}
|
|
850
856
|
};
|
|
851
857
|
$mol_func_name_from(wrapper, func);
|
|
@@ -860,6 +866,7 @@ var $;
|
|
|
860
866
|
view.childNodes = childNodes;
|
|
861
867
|
if (!view.ownerDocument)
|
|
862
868
|
view.ownerDocument = $.$mol_jsx_document;
|
|
869
|
+
view.className = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
|
|
863
870
|
node = view.valueOf();
|
|
864
871
|
node[Elem] = view;
|
|
865
872
|
return node;
|
|
@@ -867,14 +874,17 @@ var $;
|
|
|
867
874
|
else {
|
|
868
875
|
const prefix = $.$mol_jsx_prefix;
|
|
869
876
|
const booked = $.$mol_jsx_booked;
|
|
877
|
+
const crumbs = $.$mol_jsx_crumbs;
|
|
870
878
|
try {
|
|
871
879
|
$.$mol_jsx_prefix = guid;
|
|
872
880
|
$.$mol_jsx_booked = new Set;
|
|
881
|
+
$.$mol_jsx_crumbs = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
|
|
873
882
|
return Elem(props, ...childNodes);
|
|
874
883
|
}
|
|
875
884
|
finally {
|
|
876
885
|
$.$mol_jsx_prefix = prefix;
|
|
877
886
|
$.$mol_jsx_booked = booked;
|
|
887
|
+
$.$mol_jsx_crumbs = crumbs;
|
|
878
888
|
}
|
|
879
889
|
}
|
|
880
890
|
}
|
|
@@ -905,6 +915,8 @@ var $;
|
|
|
905
915
|
}
|
|
906
916
|
if (guid)
|
|
907
917
|
node.id = guid;
|
|
918
|
+
if ($.$mol_jsx_crumbs)
|
|
919
|
+
node.className = (props?.['class'] ? props['class'] + ' ' : '') + crumbs_self;
|
|
908
920
|
return node;
|
|
909
921
|
}
|
|
910
922
|
$.$mol_jsx = $mol_jsx;
|
|
@@ -1915,6 +1927,7 @@ var $;
|
|
|
1915
1927
|
}
|
|
1916
1928
|
attributes;
|
|
1917
1929
|
ownerDocument;
|
|
1930
|
+
className;
|
|
1918
1931
|
get childNodes() {
|
|
1919
1932
|
return this._kids();
|
|
1920
1933
|
}
|
|
@@ -1925,16 +1938,19 @@ var $;
|
|
|
1925
1938
|
valueOf() {
|
|
1926
1939
|
const prefix = $mol_jsx_prefix;
|
|
1927
1940
|
const booked = $mol_jsx_booked;
|
|
1941
|
+
const crumbs = $mol_jsx_crumbs;
|
|
1928
1942
|
const document = $mol_jsx_document;
|
|
1929
1943
|
try {
|
|
1930
1944
|
$mol_jsx_prefix = this[Symbol.toStringTag];
|
|
1931
1945
|
$mol_jsx_booked = new Set;
|
|
1946
|
+
$mol_jsx_crumbs = this.className;
|
|
1932
1947
|
$mol_jsx_document = this.ownerDocument;
|
|
1933
1948
|
return this.render();
|
|
1934
1949
|
}
|
|
1935
1950
|
finally {
|
|
1936
1951
|
$mol_jsx_prefix = prefix;
|
|
1937
1952
|
$mol_jsx_booked = booked;
|
|
1953
|
+
$mol_jsx_crumbs = crumbs;
|
|
1938
1954
|
$mol_jsx_document = document;
|
|
1939
1955
|
}
|
|
1940
1956
|
}
|
|
@@ -2809,7 +2825,7 @@ var $;
|
|
|
2809
2825
|
return $mol_jsx("button", { title: props.hint }, target());
|
|
2810
2826
|
};
|
|
2811
2827
|
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>');
|
|
2828
|
+
$mol_assert_equal(dom.outerHTML, '<button title="click me" id="foo" class="Button">hey!</button>');
|
|
2813
2829
|
},
|
|
2814
2830
|
'Nested guid generation'() {
|
|
2815
2831
|
const Foo = () => {
|
|
@@ -2821,7 +2837,7 @@ var $;
|
|
|
2821
2837
|
return $mol_jsx("span", null, icon);
|
|
2822
2838
|
};
|
|
2823
2839
|
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>');
|
|
2840
|
+
$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>');
|
|
2825
2841
|
},
|
|
2826
2842
|
'Fail on non unique ids'() {
|
|
2827
2843
|
const App = () => {
|
|
@@ -2834,13 +2850,13 @@ var $;
|
|
|
2834
2850
|
'Owner based guid generationn'() {
|
|
2835
2851
|
const Foo = () => {
|
|
2836
2852
|
return $mol_jsx("div", null,
|
|
2837
|
-
$mol_jsx(Bar, { id: "
|
|
2853
|
+
$mol_jsx(Bar, { id: "middle", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
|
2838
2854
|
};
|
|
2839
2855
|
const Bar = (props) => {
|
|
2840
2856
|
return $mol_jsx("span", null, props.icon());
|
|
2841
2857
|
};
|
|
2842
|
-
const dom = $mol_jsx(Foo, { id: "
|
|
2843
|
-
$mol_assert_equal(dom.outerHTML, '<div id="
|
|
2858
|
+
const dom = $mol_jsx(Foo, { id: "app" });
|
|
2859
|
+
$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>');
|
|
2844
2860
|
},
|
|
2845
2861
|
'Fail on same ids from different caller'() {
|
|
2846
2862
|
const Foo = () => {
|
|
@@ -3868,7 +3884,7 @@ var $;
|
|
|
3868
3884
|
const dom = $mol_jsx(Foo, { id: "foo", title: "bar" },
|
|
3869
3885
|
"xxx",
|
|
3870
3886
|
123);
|
|
3871
|
-
$mol_assert_equal(dom.outerHTML, '<div id="foo">bar xxx-123</div>');
|
|
3887
|
+
$mol_assert_equal(dom.outerHTML, '<div id="foo" class="Foo">bar xxx-123</div>');
|
|
3872
3888
|
},
|
|
3873
3889
|
'View by element'() {
|
|
3874
3890
|
let br;
|
|
@@ -3902,10 +3918,10 @@ var $;
|
|
|
3902
3918
|
const dom = $mol_jsx_attach(doc, () => $mol_jsx(Title, { id: "foo" }));
|
|
3903
3919
|
const title = Title.of(dom);
|
|
3904
3920
|
$mol_assert_equal(title.ownerDocument, doc);
|
|
3905
|
-
$mol_assert_equal(doc.documentElement.outerHTML, '<html><body id="foo">foo</body></html>');
|
|
3921
|
+
$mol_assert_equal(doc.documentElement.outerHTML, '<html><body id="foo" class="Title">foo</body></html>');
|
|
3906
3922
|
title.value('bar');
|
|
3907
3923
|
await $mol_wire_fiber.sync();
|
|
3908
|
-
$mol_assert_equal(doc.documentElement.outerHTML, '<html><body id="foo">bar</body></html>');
|
|
3924
|
+
$mol_assert_equal(doc.documentElement.outerHTML, '<html><body id="foo" class="Title">bar</body></html>');
|
|
3909
3925
|
},
|
|
3910
3926
|
async 'Nested bound views'($) {
|
|
3911
3927
|
class Task extends $mol_jsx_view {
|
|
@@ -3933,15 +3949,15 @@ var $;
|
|
|
3933
3949
|
], App.prototype, "title", null);
|
|
3934
3950
|
const doc = $mol_dom_parse('<html xmlns="http://www.w3.org/1999/xhtml"><body id="root"></body></html>');
|
|
3935
3951
|
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>');
|
|
3952
|
+
$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>');
|
|
3937
3953
|
App.of(root).title('barbar');
|
|
3938
3954
|
await $mol_wire_fiber.sync();
|
|
3939
3955
|
$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="root" class="list"><h1 id="root/task">barbar</h1></body></html>');
|
|
3956
|
+
$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>');
|
|
3941
3957
|
Task.of(root.firstElementChild).title('foofoo');
|
|
3942
3958
|
await $mol_wire_fiber.sync();
|
|
3943
3959
|
$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="root" class="list"><h1 id="root/task">foofoo</h1></body></html>');
|
|
3960
|
+
$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>');
|
|
3945
3961
|
},
|
|
3946
3962
|
});
|
|
3947
3963
|
})($ || ($ = {}));
|