mol_jsx_lib 0.0.56 → 0.0.57
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 +5 -0
- package/node.deps.json +1 -1
- package/node.esm.js +54 -2
- package/node.esm.js.map +1 -1
- package/node.js +54 -2
- package/node.js.map +1 -1
- package/node.test.js +91 -3
- package/node.test.js.map +1 -1
- package/package.json +3 -1
- package/web.d.ts +5 -0
- package/web.deps.json +1 -1
- package/web.esm.js +54 -2
- package/web.esm.js.map +1 -1
- package/web.js +54 -2
- package/web.js.map +1 -1
- package/web.test.js +37 -1
- package/web.test.js.map +1 -1
package/web.js
CHANGED
|
@@ -54,6 +54,34 @@ var $;
|
|
|
54
54
|
;
|
|
55
55
|
"use strict";
|
|
56
56
|
var $;
|
|
57
|
+
(function ($) {
|
|
58
|
+
function $mol_func_name(func) {
|
|
59
|
+
let name = func.name;
|
|
60
|
+
if (name?.length > 1)
|
|
61
|
+
return name;
|
|
62
|
+
for (let key in this) {
|
|
63
|
+
try {
|
|
64
|
+
if (this[key] !== func)
|
|
65
|
+
continue;
|
|
66
|
+
name = key;
|
|
67
|
+
Object.defineProperty(func, 'name', { value: name });
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
catch { }
|
|
71
|
+
}
|
|
72
|
+
return name;
|
|
73
|
+
}
|
|
74
|
+
$.$mol_func_name = $mol_func_name;
|
|
75
|
+
function $mol_func_name_from(target, source) {
|
|
76
|
+
Object.defineProperty(target, 'name', { value: source.name });
|
|
77
|
+
return target;
|
|
78
|
+
}
|
|
79
|
+
$.$mol_func_name_from = $mol_func_name_from;
|
|
80
|
+
})($ || ($ = {}));
|
|
81
|
+
//mol/func/name/name.ts
|
|
82
|
+
;
|
|
83
|
+
"use strict";
|
|
84
|
+
var $;
|
|
57
85
|
(function ($) {
|
|
58
86
|
function $mol_dom_render_children(el, childNodes) {
|
|
59
87
|
const node_set = new Set(childNodes);
|
|
@@ -123,16 +151,40 @@ var $;
|
|
|
123
151
|
$.$mol_jsx_frag = '';
|
|
124
152
|
function $mol_jsx(Elem, props, ...childNodes) {
|
|
125
153
|
const id = props && props.id || '';
|
|
154
|
+
const guid = $.$mol_jsx_prefix + id;
|
|
126
155
|
if (Elem && $.$mol_jsx_booked) {
|
|
127
156
|
if ($.$mol_jsx_booked.has(id)) {
|
|
128
|
-
$mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(
|
|
157
|
+
$mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`));
|
|
129
158
|
}
|
|
130
159
|
else {
|
|
131
160
|
$.$mol_jsx_booked.add(id);
|
|
132
161
|
}
|
|
133
162
|
}
|
|
134
|
-
const guid = $.$mol_jsx_prefix + id;
|
|
135
163
|
let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
|
|
164
|
+
if ($.$mol_jsx_prefix) {
|
|
165
|
+
const prefix_ext = $.$mol_jsx_prefix;
|
|
166
|
+
const booked_ext = $.$mol_jsx_booked;
|
|
167
|
+
for (const field in props) {
|
|
168
|
+
const func = props[field];
|
|
169
|
+
if (typeof func !== 'function')
|
|
170
|
+
continue;
|
|
171
|
+
const wrapper = function (...args) {
|
|
172
|
+
const prefix = $.$mol_jsx_prefix;
|
|
173
|
+
const booked = $.$mol_jsx_booked;
|
|
174
|
+
try {
|
|
175
|
+
$.$mol_jsx_prefix = prefix_ext;
|
|
176
|
+
$.$mol_jsx_booked = booked_ext;
|
|
177
|
+
return func.call(this, ...args);
|
|
178
|
+
}
|
|
179
|
+
finally {
|
|
180
|
+
$.$mol_jsx_prefix = prefix;
|
|
181
|
+
$.$mol_jsx_booked = booked;
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
$mol_func_name_from(wrapper, func);
|
|
185
|
+
props[field] = wrapper;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
136
188
|
if (typeof Elem !== 'string') {
|
|
137
189
|
if ('prototype' in Elem) {
|
|
138
190
|
const view = node && node[Elem] || new Elem;
|