mol_plot_all 1.2.256 → 1.2.259

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mol_plot_all",
3
- "version": "1.2.256",
3
+ "version": "1.2.259",
4
4
  "main": "node.js",
5
5
  "module": "node.esm.js",
6
6
  "browser": "web.js",
package/web.test.js CHANGED
@@ -160,28 +160,52 @@ var $;
160
160
  const Button = (props, target) => {
161
161
  return $mol_jsx("button", { title: props.hint }, target());
162
162
  };
163
- const dom = $mol_jsx(Button, { id: "/foo", hint: "click me" }, () => 'hey!');
164
- $mol_assert_equal(dom.outerHTML, '<button title="click me" id="/foo">hey!</button>');
163
+ const dom = $mol_jsx(Button, { id: "foo", hint: "click me" }, () => 'hey!');
164
+ $mol_assert_equal(dom.outerHTML, '<button title="click me" id="foo" class="Button">hey!</button>');
165
165
  },
166
166
  'Nested guid generation'() {
167
167
  const Foo = () => {
168
168
  return $mol_jsx("div", null,
169
- $mol_jsx(Bar, { id: "/bar" },
170
- $mol_jsx("img", { id: "/icon" })));
169
+ $mol_jsx(Bar, { id: "bar" },
170
+ $mol_jsx("img", { id: "icon" })));
171
171
  };
172
172
  const Bar = (props, icon) => {
173
- return $mol_jsx("span", null, icon);
173
+ return $mol_jsx("span", null,
174
+ icon,
175
+ $mol_jsx("i", { id: "label" }));
174
176
  };
175
- const dom = $mol_jsx(Foo, { id: "/foo" });
176
- $mol_assert_equal(dom.outerHTML, '<div id="/foo"><span id="/foo/bar"><img id="/foo/icon"></span></div>');
177
+ const dom = $mol_jsx(Foo, { id: "foo" });
178
+ $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>');
177
179
  },
178
180
  'Fail on non unique ids'() {
179
181
  const App = () => {
180
182
  return $mol_jsx("div", null,
181
- $mol_jsx("span", { id: "/bar" }),
182
- $mol_jsx("span", { id: "/bar" }));
183
+ $mol_jsx("span", { id: "bar" }),
184
+ $mol_jsx("span", { id: "bar" }));
183
185
  };
184
- $mol_assert_fail(() => $mol_jsx(App, { id: "/foo" }), 'JSX already has tag with id "/bar"');
186
+ $mol_assert_fail(() => $mol_jsx(App, { id: "foo" }), 'JSX already has tag with id "foo/bar"');
187
+ },
188
+ 'Owner based guid generationn'() {
189
+ const Foo = () => {
190
+ return $mol_jsx("div", null,
191
+ $mol_jsx(Bar, { id: "middle", icon: () => $mol_jsx("img", { id: "icon" }) }));
192
+ };
193
+ const Bar = (props) => {
194
+ return $mol_jsx("span", null, props.icon());
195
+ };
196
+ const dom = $mol_jsx(Foo, { id: "app" });
197
+ $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>');
198
+ },
199
+ 'Fail on same ids from different caller'() {
200
+ const Foo = () => {
201
+ return $mol_jsx("div", null,
202
+ $mol_jsx("img", { id: "icon" }),
203
+ $mol_jsx(Bar, { id: "bar", icon: () => $mol_jsx("img", { id: "icon" }) }));
204
+ };
205
+ const Bar = (props) => {
206
+ return $mol_jsx("span", null, props.icon());
207
+ };
208
+ $mol_assert_fail(() => $mol_jsx(Foo, { id: "foo" }), 'JSX already has tag with id "foo/icon"');
185
209
  },
186
210
  });
187
211
  })($ || ($ = {}));
@@ -191,6 +215,7 @@ var $;
191
215
  var $;
192
216
  (function ($) {
193
217
  $.$mol_jsx_prefix = '';
218
+ $.$mol_jsx_crumbs = '';
194
219
  $.$mol_jsx_booked = null;
195
220
  $.$mol_jsx_document = {
196
221
  getElementById: () => null,
@@ -200,16 +225,45 @@ var $;
200
225
  $.$mol_jsx_frag = '';
201
226
  function $mol_jsx(Elem, props, ...childNodes) {
202
227
  const id = props && props.id || '';
228
+ const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
229
+ const crumbs_self = id ? $.$mol_jsx_crumbs.replace(/(\S+)/g, `$1_${id}`) : $.$mol_jsx_crumbs;
203
230
  if (Elem && $.$mol_jsx_booked) {
204
231
  if ($.$mol_jsx_booked.has(id)) {
205
- $mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(id)}`));
232
+ $mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`));
206
233
  }
207
234
  else {
208
235
  $.$mol_jsx_booked.add(id);
209
236
  }
210
237
  }
211
- const guid = $.$mol_jsx_prefix + id;
212
238
  let node = guid ? $.$mol_jsx_document.getElementById(guid) : null;
239
+ if ($.$mol_jsx_prefix) {
240
+ const prefix_ext = $.$mol_jsx_prefix;
241
+ const booked_ext = $.$mol_jsx_booked;
242
+ const crumbs_ext = $.$mol_jsx_crumbs;
243
+ for (const field in props) {
244
+ const func = props[field];
245
+ if (typeof func !== 'function')
246
+ continue;
247
+ const wrapper = function (...args) {
248
+ const prefix = $.$mol_jsx_prefix;
249
+ const booked = $.$mol_jsx_booked;
250
+ const crumbs = $.$mol_jsx_crumbs;
251
+ try {
252
+ $.$mol_jsx_prefix = prefix_ext;
253
+ $.$mol_jsx_booked = booked_ext;
254
+ $.$mol_jsx_crumbs = crumbs_ext;
255
+ return func.call(this, ...args);
256
+ }
257
+ finally {
258
+ $.$mol_jsx_prefix = prefix;
259
+ $.$mol_jsx_booked = booked;
260
+ $.$mol_jsx_crumbs = crumbs;
261
+ }
262
+ };
263
+ $mol_func_name_from(wrapper, func);
264
+ props[field] = wrapper;
265
+ }
266
+ }
213
267
  if (typeof Elem !== 'string') {
214
268
  if ('prototype' in Elem) {
215
269
  const view = node && node[Elem] || new Elem;
@@ -218,6 +272,7 @@ var $;
218
272
  view.childNodes = childNodes;
219
273
  if (!view.ownerDocument)
220
274
  view.ownerDocument = $.$mol_jsx_document;
275
+ view.className = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
221
276
  node = view.valueOf();
222
277
  node[Elem] = view;
223
278
  return node;
@@ -225,14 +280,17 @@ var $;
225
280
  else {
226
281
  const prefix = $.$mol_jsx_prefix;
227
282
  const booked = $.$mol_jsx_booked;
283
+ const crumbs = $.$mol_jsx_crumbs;
228
284
  try {
229
285
  $.$mol_jsx_prefix = guid;
230
286
  $.$mol_jsx_booked = new Set;
287
+ $.$mol_jsx_crumbs = (crumbs_self ? crumbs_self + ' ' : '') + (Elem['name'] || Elem);
231
288
  return Elem(props, ...childNodes);
232
289
  }
233
290
  finally {
234
291
  $.$mol_jsx_prefix = prefix;
235
292
  $.$mol_jsx_booked = booked;
293
+ $.$mol_jsx_crumbs = crumbs;
236
294
  }
237
295
  }
238
296
  }
@@ -263,6 +321,8 @@ var $;
263
321
  }
264
322
  if (guid)
265
323
  node.id = guid;
324
+ if ($.$mol_jsx_crumbs)
325
+ node.className = (props?.['class'] ? props['class'] + ' ' : '') + crumbs_self;
266
326
  return node;
267
327
  }
268
328
  $.$mol_jsx = $mol_jsx;
@@ -503,6 +563,20 @@ var $;
503
563
  ;
504
564
  "use strict";
505
565
  var $;
566
+ (function ($_1) {
567
+ $mol_test({
568
+ 'FQN of anon function'($) {
569
+ const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
570
+ $mol_assert_equal($$.$mol_func_name_test.name, '');
571
+ $mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
572
+ $mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
573
+ },
574
+ });
575
+ })($ || ($ = {}));
576
+ //mol/func/name/name.test.ts
577
+ ;
578
+ "use strict";
579
+ var $;
506
580
  (function ($) {
507
581
  $mol_test({
508
582
  'get'() {
@@ -1827,20 +1901,6 @@ var $;
1827
1901
  ;
1828
1902
  "use strict";
1829
1903
  var $;
1830
- (function ($_1) {
1831
- $mol_test({
1832
- 'FQN of anon function'($) {
1833
- const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
1834
- $mol_assert_equal($$.$mol_func_name_test.name, '');
1835
- $mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
1836
- $mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
1837
- },
1838
- });
1839
- })($ || ($ = {}));
1840
- //mol/func/name/name.test.ts
1841
- ;
1842
- "use strict";
1843
- var $;
1844
1904
  (function ($_1) {
1845
1905
  $mol_test({
1846
1906
  'id auto generation'($) {