mol_jsx_lib 0.0.56 → 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/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);
@@ -114,6 +142,7 @@ var $;
114
142
  var $;
115
143
  (function ($) {
116
144
  $.$mol_jsx_prefix = '';
145
+ $.$mol_jsx_crumbs = '';
117
146
  $.$mol_jsx_booked = null;
118
147
  $.$mol_jsx_document = {
119
148
  getElementById: () => null,
@@ -123,16 +152,45 @@ var $;
123
152
  $.$mol_jsx_frag = '';
124
153
  function $mol_jsx(Elem, props, ...childNodes) {
125
154
  const id = props && props.id || '';
155
+ const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
156
+ const crumbs_self = id ? $.$mol_jsx_crumbs.replace(/([^ ]+)/, `$1_${id}`) : $.$mol_jsx_crumbs;
126
157
  if (Elem && $.$mol_jsx_booked) {
127
158
  if ($.$mol_jsx_booked.has(id)) {
128
- $mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(id)}`));
159
+ $mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`));
129
160
  }
130
161
  else {
131
162
  $.$mol_jsx_booked.add(id);
132
163
  }
133
164
  }
134
- const guid = $.$mol_jsx_prefix + id;
135
165
  let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
166
+ if ($.$mol_jsx_prefix) {
167
+ const prefix_ext = $.$mol_jsx_prefix;
168
+ const booked_ext = $.$mol_jsx_booked;
169
+ const crumbs_ext = $.$mol_jsx_crumbs;
170
+ for (const field in props) {
171
+ const func = props[field];
172
+ if (typeof func !== 'function')
173
+ continue;
174
+ const wrapper = function (...args) {
175
+ const prefix = $.$mol_jsx_prefix;
176
+ const booked = $.$mol_jsx_booked;
177
+ const crumbs = $.$mol_jsx_crumbs;
178
+ try {
179
+ $.$mol_jsx_prefix = prefix_ext;
180
+ $.$mol_jsx_booked = booked_ext;
181
+ $.$mol_jsx_crumbs = crumbs_ext;
182
+ return func.call(this, ...args);
183
+ }
184
+ finally {
185
+ $.$mol_jsx_prefix = prefix;
186
+ $.$mol_jsx_booked = booked;
187
+ $.$mol_jsx_crumbs = crumbs;
188
+ }
189
+ };
190
+ $mol_func_name_from(wrapper, func);
191
+ props[field] = wrapper;
192
+ }
193
+ }
136
194
  if (typeof Elem !== 'string') {
137
195
  if ('prototype' in Elem) {
138
196
  const view = node && node[Elem] || new Elem;
@@ -141,6 +199,7 @@ var $;
141
199
  view.childNodes = childNodes;
142
200
  if (!view.ownerDocument)
143
201
  view.ownerDocument = $.$mol_jsx_document;
202
+ view.className = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
144
203
  node = view.valueOf();
145
204
  node[Elem] = view;
146
205
  return node;
@@ -148,14 +207,17 @@ var $;
148
207
  else {
149
208
  const prefix = $.$mol_jsx_prefix;
150
209
  const booked = $.$mol_jsx_booked;
210
+ const crumbs = $.$mol_jsx_crumbs;
151
211
  try {
152
212
  $.$mol_jsx_prefix = guid;
153
213
  $.$mol_jsx_booked = new Set;
214
+ $.$mol_jsx_crumbs = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
154
215
  return Elem(props, ...childNodes);
155
216
  }
156
217
  finally {
157
218
  $.$mol_jsx_prefix = prefix;
158
219
  $.$mol_jsx_booked = booked;
220
+ $.$mol_jsx_crumbs = crumbs;
159
221
  }
160
222
  }
161
223
  }
@@ -186,6 +248,8 @@ var $;
186
248
  }
187
249
  if (guid)
188
250
  node.id = guid;
251
+ if ($.$mol_jsx_crumbs)
252
+ node.className = (props?.['class'] ? props['class'] + ' ' : '') + crumbs_self;
189
253
  return node;
190
254
  }
191
255
  $.$mol_jsx = $mol_jsx;
@@ -1362,6 +1426,7 @@ var $;
1362
1426
  }
1363
1427
  attributes;
1364
1428
  ownerDocument;
1429
+ className;
1365
1430
  get childNodes() {
1366
1431
  return this._kids();
1367
1432
  }
@@ -1372,16 +1437,19 @@ var $;
1372
1437
  valueOf() {
1373
1438
  const prefix = $mol_jsx_prefix;
1374
1439
  const booked = $mol_jsx_booked;
1440
+ const crumbs = $mol_jsx_crumbs;
1375
1441
  const document = $mol_jsx_document;
1376
1442
  try {
1377
1443
  $mol_jsx_prefix = this[Symbol.toStringTag];
1378
1444
  $mol_jsx_booked = new Set;
1445
+ $mol_jsx_crumbs = this.className;
1379
1446
  $mol_jsx_document = this.ownerDocument;
1380
1447
  return this.render();
1381
1448
  }
1382
1449
  finally {
1383
1450
  $mol_jsx_prefix = prefix;
1384
1451
  $mol_jsx_booked = booked;
1452
+ $mol_jsx_crumbs = crumbs;
1385
1453
  $mol_jsx_document = document;
1386
1454
  }
1387
1455
  }