mol_time_all 1.1.234 → 1.1.237
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 +118 -14
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.test.js +118 -14
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -1092,28 +1092,52 @@ var $;
|
|
|
1092
1092
|
const Button = (props, target) => {
|
|
1093
1093
|
return $mol_jsx("button", { title: props.hint }, target());
|
|
1094
1094
|
};
|
|
1095
|
-
const dom = $mol_jsx(Button, { id: "
|
|
1096
|
-
$mol_assert_equal(dom.outerHTML, '<button title="click me"
|
|
1095
|
+
const dom = $mol_jsx(Button, { id: "foo", hint: "click me" }, () => 'hey!');
|
|
1096
|
+
$mol_assert_equal(dom.outerHTML, '<button id="foo" title="click me" class="Button">hey!</button>');
|
|
1097
1097
|
},
|
|
1098
1098
|
'Nested guid generation'() {
|
|
1099
1099
|
const Foo = () => {
|
|
1100
1100
|
return $mol_jsx("div", null,
|
|
1101
|
-
$mol_jsx(Bar, { id: "
|
|
1102
|
-
$mol_jsx("img", { id: "
|
|
1101
|
+
$mol_jsx(Bar, { id: "bar" },
|
|
1102
|
+
$mol_jsx("img", { id: "icon" })));
|
|
1103
1103
|
};
|
|
1104
1104
|
const Bar = (props, icon) => {
|
|
1105
|
-
return $mol_jsx("span", null,
|
|
1105
|
+
return $mol_jsx("span", null,
|
|
1106
|
+
icon,
|
|
1107
|
+
$mol_jsx("i", { id: "label" }));
|
|
1106
1108
|
};
|
|
1107
|
-
const dom = $mol_jsx(Foo, { id: "
|
|
1108
|
-
$mol_assert_equal(dom.outerHTML, '<div id="
|
|
1109
|
+
const dom = $mol_jsx(Foo, { id: "foo" });
|
|
1110
|
+
$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>');
|
|
1109
1111
|
},
|
|
1110
1112
|
'Fail on non unique ids'() {
|
|
1111
1113
|
const App = () => {
|
|
1112
1114
|
return $mol_jsx("div", null,
|
|
1113
|
-
$mol_jsx("span", { id: "
|
|
1114
|
-
$mol_jsx("span", { id: "
|
|
1115
|
+
$mol_jsx("span", { id: "bar" }),
|
|
1116
|
+
$mol_jsx("span", { id: "bar" }));
|
|
1115
1117
|
};
|
|
1116
|
-
$mol_assert_fail(() => $mol_jsx(App, { id: "
|
|
1118
|
+
$mol_assert_fail(() => $mol_jsx(App, { id: "foo" }), 'JSX already has tag with id "foo/bar"');
|
|
1119
|
+
},
|
|
1120
|
+
'Owner based guid generationn'() {
|
|
1121
|
+
const Foo = () => {
|
|
1122
|
+
return $mol_jsx("div", null,
|
|
1123
|
+
$mol_jsx(Bar, { id: "middle", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
|
1124
|
+
};
|
|
1125
|
+
const Bar = (props) => {
|
|
1126
|
+
return $mol_jsx("span", null, props.icon());
|
|
1127
|
+
};
|
|
1128
|
+
const dom = $mol_jsx(Foo, { id: "app" });
|
|
1129
|
+
$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>');
|
|
1130
|
+
},
|
|
1131
|
+
'Fail on same ids from different caller'() {
|
|
1132
|
+
const Foo = () => {
|
|
1133
|
+
return $mol_jsx("div", null,
|
|
1134
|
+
$mol_jsx("img", { id: "icon" }),
|
|
1135
|
+
$mol_jsx(Bar, { id: "bar", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
|
1136
|
+
};
|
|
1137
|
+
const Bar = (props) => {
|
|
1138
|
+
return $mol_jsx("span", null, props.icon());
|
|
1139
|
+
};
|
|
1140
|
+
$mol_assert_fail(() => $mol_jsx(Foo, { id: "foo" }), 'JSX already has tag with id "foo/icon"');
|
|
1117
1141
|
},
|
|
1118
1142
|
});
|
|
1119
1143
|
})($ || ($ = {}));
|
|
@@ -1123,6 +1147,7 @@ var $;
|
|
|
1123
1147
|
var $;
|
|
1124
1148
|
(function ($) {
|
|
1125
1149
|
$.$mol_jsx_prefix = '';
|
|
1150
|
+
$.$mol_jsx_crumbs = '';
|
|
1126
1151
|
$.$mol_jsx_booked = null;
|
|
1127
1152
|
$.$mol_jsx_document = {
|
|
1128
1153
|
getElementById: () => null,
|
|
@@ -1132,16 +1157,45 @@ var $;
|
|
|
1132
1157
|
$.$mol_jsx_frag = '';
|
|
1133
1158
|
function $mol_jsx(Elem, props, ...childNodes) {
|
|
1134
1159
|
const id = props && props.id || '';
|
|
1160
|
+
const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
|
|
1161
|
+
const crumbs_self = id ? $.$mol_jsx_crumbs.replace(/(\S+)/g, `$1_${id.replace(/\/.*/i, '')}`) : $.$mol_jsx_crumbs;
|
|
1135
1162
|
if (Elem && $.$mol_jsx_booked) {
|
|
1136
1163
|
if ($.$mol_jsx_booked.has(id)) {
|
|
1137
|
-
$mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(
|
|
1164
|
+
$mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`));
|
|
1138
1165
|
}
|
|
1139
1166
|
else {
|
|
1140
1167
|
$.$mol_jsx_booked.add(id);
|
|
1141
1168
|
}
|
|
1142
1169
|
}
|
|
1143
|
-
const guid = $.$mol_jsx_prefix + id;
|
|
1144
1170
|
let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
|
|
1171
|
+
if ($.$mol_jsx_prefix) {
|
|
1172
|
+
const prefix_ext = $.$mol_jsx_prefix;
|
|
1173
|
+
const booked_ext = $.$mol_jsx_booked;
|
|
1174
|
+
const crumbs_ext = $.$mol_jsx_crumbs;
|
|
1175
|
+
for (const field in props) {
|
|
1176
|
+
const func = props[field];
|
|
1177
|
+
if (typeof func !== 'function')
|
|
1178
|
+
continue;
|
|
1179
|
+
const wrapper = function (...args) {
|
|
1180
|
+
const prefix = $.$mol_jsx_prefix;
|
|
1181
|
+
const booked = $.$mol_jsx_booked;
|
|
1182
|
+
const crumbs = $.$mol_jsx_crumbs;
|
|
1183
|
+
try {
|
|
1184
|
+
$.$mol_jsx_prefix = prefix_ext;
|
|
1185
|
+
$.$mol_jsx_booked = booked_ext;
|
|
1186
|
+
$.$mol_jsx_crumbs = crumbs_ext;
|
|
1187
|
+
return func.call(this, ...args);
|
|
1188
|
+
}
|
|
1189
|
+
finally {
|
|
1190
|
+
$.$mol_jsx_prefix = prefix;
|
|
1191
|
+
$.$mol_jsx_booked = booked;
|
|
1192
|
+
$.$mol_jsx_crumbs = crumbs;
|
|
1193
|
+
}
|
|
1194
|
+
};
|
|
1195
|
+
$mol_func_name_from(wrapper, func);
|
|
1196
|
+
props[field] = wrapper;
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1145
1199
|
if (typeof Elem !== 'string') {
|
|
1146
1200
|
if ('prototype' in Elem) {
|
|
1147
1201
|
const view = node && node[Elem] || new Elem;
|
|
@@ -1150,6 +1204,7 @@ var $;
|
|
|
1150
1204
|
view.childNodes = childNodes;
|
|
1151
1205
|
if (!view.ownerDocument)
|
|
1152
1206
|
view.ownerDocument = $.$mol_jsx_document;
|
|
1207
|
+
view.className = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
|
|
1153
1208
|
node = view.valueOf();
|
|
1154
1209
|
node[Elem] = view;
|
|
1155
1210
|
return node;
|
|
@@ -1157,14 +1212,17 @@ var $;
|
|
|
1157
1212
|
else {
|
|
1158
1213
|
const prefix = $.$mol_jsx_prefix;
|
|
1159
1214
|
const booked = $.$mol_jsx_booked;
|
|
1215
|
+
const crumbs = $.$mol_jsx_crumbs;
|
|
1160
1216
|
try {
|
|
1161
1217
|
$.$mol_jsx_prefix = guid;
|
|
1162
1218
|
$.$mol_jsx_booked = new Set;
|
|
1219
|
+
$.$mol_jsx_crumbs = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
|
|
1163
1220
|
return Elem(props, ...childNodes);
|
|
1164
1221
|
}
|
|
1165
1222
|
finally {
|
|
1166
1223
|
$.$mol_jsx_prefix = prefix;
|
|
1167
1224
|
$.$mol_jsx_booked = booked;
|
|
1225
|
+
$.$mol_jsx_crumbs = crumbs;
|
|
1168
1226
|
}
|
|
1169
1227
|
}
|
|
1170
1228
|
}
|
|
@@ -1176,7 +1234,11 @@ var $;
|
|
|
1176
1234
|
$mol_dom_render_children(node, [].concat(...childNodes));
|
|
1177
1235
|
if (!Elem)
|
|
1178
1236
|
return node;
|
|
1237
|
+
if (guid)
|
|
1238
|
+
node.id = guid;
|
|
1179
1239
|
for (const key in props) {
|
|
1240
|
+
if (key === 'id')
|
|
1241
|
+
continue;
|
|
1180
1242
|
if (typeof props[key] === 'string') {
|
|
1181
1243
|
;
|
|
1182
1244
|
node.setAttribute(key, props[key]);
|
|
@@ -1193,8 +1255,8 @@ var $;
|
|
|
1193
1255
|
node[key] = props[key];
|
|
1194
1256
|
}
|
|
1195
1257
|
}
|
|
1196
|
-
if (
|
|
1197
|
-
node.
|
|
1258
|
+
if ($.$mol_jsx_crumbs)
|
|
1259
|
+
node.className = (props?.['class'] ? props['class'] + ' ' : '') + crumbs_self;
|
|
1198
1260
|
return node;
|
|
1199
1261
|
}
|
|
1200
1262
|
$.$mol_jsx = $mol_jsx;
|
|
@@ -2190,6 +2252,48 @@ var $;
|
|
|
2190
2252
|
;
|
|
2191
2253
|
"use strict";
|
|
2192
2254
|
var $;
|
|
2255
|
+
(function ($_1) {
|
|
2256
|
+
$mol_test({
|
|
2257
|
+
'FQN of anon function'($) {
|
|
2258
|
+
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
2259
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
2260
|
+
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
2261
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
2262
|
+
},
|
|
2263
|
+
});
|
|
2264
|
+
})($ || ($ = {}));
|
|
2265
|
+
//mol/func/name/name.test.ts
|
|
2266
|
+
;
|
|
2267
|
+
"use strict";
|
|
2268
|
+
var $;
|
|
2269
|
+
(function ($) {
|
|
2270
|
+
function $mol_func_name(func) {
|
|
2271
|
+
let name = func.name;
|
|
2272
|
+
if (name?.length > 1)
|
|
2273
|
+
return name;
|
|
2274
|
+
for (let key in this) {
|
|
2275
|
+
try {
|
|
2276
|
+
if (this[key] !== func)
|
|
2277
|
+
continue;
|
|
2278
|
+
name = key;
|
|
2279
|
+
Object.defineProperty(func, 'name', { value: name });
|
|
2280
|
+
break;
|
|
2281
|
+
}
|
|
2282
|
+
catch { }
|
|
2283
|
+
}
|
|
2284
|
+
return name;
|
|
2285
|
+
}
|
|
2286
|
+
$.$mol_func_name = $mol_func_name;
|
|
2287
|
+
function $mol_func_name_from(target, source) {
|
|
2288
|
+
Object.defineProperty(target, 'name', { value: source.name });
|
|
2289
|
+
return target;
|
|
2290
|
+
}
|
|
2291
|
+
$.$mol_func_name_from = $mol_func_name_from;
|
|
2292
|
+
})($ || ($ = {}));
|
|
2293
|
+
//mol/func/name/name.ts
|
|
2294
|
+
;
|
|
2295
|
+
"use strict";
|
|
2296
|
+
var $;
|
|
2193
2297
|
(function ($) {
|
|
2194
2298
|
$mol_test({
|
|
2195
2299
|
'parse and serial'() {
|