@yuneta/gobj-ui 7.26.13 → 7.26.15

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.
@@ -176,6 +176,13 @@ let PRIVATE_DATA = {
176
176
  * that landing, which must not navigate. */
177
177
  restore_hash: "",
178
178
  skip_hash: "",
179
+ /* A route pushed (yui_shell_navigate) while a back() of ours was in
180
+ * flight: it is navigated once the back() is over, or the traversal
181
+ * would run from it and undo it. */
182
+ deferred_route: "",
183
+ /* Bounds the wait for that back(): one that never lands must not
184
+ * hold every later navigation for ever. */
185
+ deferred_timer: null,
179
186
  popstate_handler: null,
180
187
  /* Avatar item support — every toolbar item with type:"avatar"
181
188
  * registers its <span> here so refresh_avatars() can repaint
@@ -426,14 +433,25 @@ function mt_start(gobj)
426
433
  * overlay's marker) closes the top overlay: strict
427
434
  * LIFO. */
428
435
  let st = ev && ev.state;
429
- if(st && st.__yui_overlay__ === top.id) {
436
+ if(!st) {
437
+ /* An entry with no state is a FRESH one: a push (a
438
+ * link, `location.hash = ...`) fires popstate too, and a
439
+ * link to the hash the panel was opened on is not a
440
+ * Back. A step off a marker lands on the entry under it,
441
+ * which push_overlay_marker() stamped, or on a lower
442
+ * overlay's marker. */
430
443
  return;
431
444
  }
432
- if(st && st.__yui_overlay__ > top.id &&
445
+ if(st.__yui_overlay__ === top.id) {
446
+ return;
447
+ }
448
+ if(st.__yui_overlay__ > top.id &&
433
449
  !p.overlay_stack.some(e => e.id === st.__yui_overlay__)) {
434
- /* A dead marker NEWER than the top: only Forward reaches
435
- * it (an overlay closed by its button above this one).
436
- * It is not a step off the top's marker. */
450
+ /* A dead marker NEWER than the top: Forward reaches it
451
+ * (an overlay closed by its button above this one), and
452
+ * so does a Back onto the marker of an overlay a
453
+ * navigation drained under a panel that stayed. It is
454
+ * not a step off the top's marker. */
437
455
  return;
438
456
  }
439
457
  p.overlay_stack.pop();
@@ -442,6 +460,21 @@ function mt_start(gobj)
442
460
  } catch(e) {
443
461
  log_warning(`C_YUI_SHELL: overlay close on Back failed: ${e}`);
444
462
  }
463
+ if(typeof top.below_hash === "string" && top.hash !== top.below_hash &&
464
+ window.location.hash === top.below_hash) {
465
+ /* A replace navigation had written the view's position
466
+ * on the marker, and stepping off it landed on the entry
467
+ * under it, on the old hash: put the position back, and
468
+ * let the hashchange of this landing pass -- Back closed
469
+ * the panel, it did not move the view. */
470
+ try {
471
+ window.history.replaceState(window.history.state, "", top.hash);
472
+ p.skip_hash = top.hash;
473
+ p.last_hash = top.hash;
474
+ } catch(e) {
475
+ log_warning(`C_YUI_SHELL: restoring '${top.hash}' failed: ${e}`);
476
+ }
477
+ }
445
478
  };
446
479
  window.addEventListener("popstate", priv.popstate_handler);
447
480
  }
@@ -522,6 +555,8 @@ function mt_stop(gobj)
522
555
  priv.markers_after_hashchange = false;
523
556
  priv.restore_hash = "";
524
557
  priv.skip_hash = "";
558
+ priv.deferred_route = "";
559
+ clear_deferred_timer(gobj);
525
560
  if(priv.keydown_handler) {
526
561
  window.removeEventListener("keydown", priv.keydown_handler);
527
562
  priv.keydown_handler = null;
@@ -2761,6 +2796,19 @@ function push_overlay_marker(gobj, entry)
2761
2796
  * marker lands there -- even after a replace-navigation rewrote the
2762
2797
  * marker's own hash (retag_overlay_hash()). */
2763
2798
  entry.below_hash = window.location.hash;
2799
+ /* Stamp the entry under the marker: a step off the marker lands on
2800
+ * it, and a push (a link, `location.hash = ...`) lands on a fresh
2801
+ * entry with no state -- both fire popstate, on the same hash when
2802
+ * the link points where the overlay was opened, and the state is
2803
+ * the only thing that tells them apart. An entry with a state of
2804
+ * its own (a lower marker, an app's) keeps it. */
2805
+ if(window.history.state === null) {
2806
+ try {
2807
+ window.history.replaceState({ __yui_below__: entry.id }, "");
2808
+ } catch(e) {
2809
+ log_warning(`C_YUI_SHELL: stamping the entry under an overlay failed: ${e}`);
2810
+ }
2811
+ }
2764
2812
  try {
2765
2813
  window.history.pushState({ __yui_overlay__: entry.id }, "");
2766
2814
  } catch(e) {
@@ -2792,10 +2840,68 @@ function drop_expected_pops(gobj)
2792
2840
  );
2793
2841
  priv.expected_pops = 0;
2794
2842
  priv.expected_pop_hash = "";
2843
+ clear_deferred_timer(gobj);
2844
+ if(priv.deferred_route) {
2845
+ /* The history moved on under it (a link, a Back): that move is
2846
+ * the newer one, and running the route after it would undo it. */
2847
+ log_warning(
2848
+ `C_YUI_SHELL: route '${priv.deferred_route}' waited for that ` +
2849
+ `back() and is dropped: the history moved on to '${window.location.hash}'`
2850
+ );
2851
+ priv.deferred_route = "";
2852
+ }
2795
2853
  /* The caller pushes the waiting markers, once it has handled the
2796
2854
  * traversal that told it. */
2797
2855
  }
2798
2856
 
2857
+ /* A route pushed while a back() of ours is in flight waits for it to
2858
+ * land (push_pending_markers() navigates it), and a newer one takes
2859
+ * its place, said out loud. The wait is bounded: a back() that never
2860
+ * lands, with nothing else moving the history to say so, would hold
2861
+ * every later navigation. */
2862
+ const DEFERRED_ROUTE_WAIT_MS = 1000;
2863
+
2864
+ function defer_route(gobj, route)
2865
+ {
2866
+ let priv = gobj.priv;
2867
+ if(priv.deferred_route && priv.deferred_route !== route) {
2868
+ log_warning(
2869
+ `C_YUI_SHELL: route '${priv.deferred_route}' waiting for a back() ` +
2870
+ `of ours is replaced by '${route}'`
2871
+ );
2872
+ }
2873
+ priv.deferred_route = route;
2874
+ if(!priv.deferred_timer) {
2875
+ priv.deferred_timer = window.setTimeout(() => {
2876
+ let p = gobj.priv;
2877
+ if(!p) {
2878
+ return;
2879
+ }
2880
+ p.deferred_timer = null;
2881
+ if(p.expected_pops === 0) {
2882
+ return;
2883
+ }
2884
+ log_warning(
2885
+ `C_YUI_SHELL: ${p.expected_pops} history.back() of ours did not ` +
2886
+ `land in ${DEFERRED_ROUTE_WAIT_MS} ms, given up`
2887
+ );
2888
+ p.expected_pops = 0;
2889
+ p.expected_pop_hash = "";
2890
+ p.restore_hash = "";
2891
+ push_pending_markers(gobj); // and navigates the deferred route
2892
+ }, DEFERRED_ROUTE_WAIT_MS);
2893
+ }
2894
+ }
2895
+
2896
+ function clear_deferred_timer(gobj)
2897
+ {
2898
+ let priv = gobj.priv;
2899
+ if(priv.deferred_timer) {
2900
+ window.clearTimeout(priv.deferred_timer);
2901
+ priv.deferred_timer = null;
2902
+ }
2903
+ }
2904
+
2799
2905
  /* The history.back() calls of ours have all landed: push the markers of
2800
2906
  * the overlays registered meanwhile, in their order. One closed in the
2801
2907
  * meantime (dismissed, drained, or no longer on the stack) has none. */
@@ -2813,6 +2919,12 @@ function push_pending_markers(gobj)
2813
2919
  entry.hash = window.location.hash;
2814
2920
  push_overlay_marker(gobj, entry); // Error already logged
2815
2921
  }
2922
+ clear_deferred_timer(gobj);
2923
+ if(priv.deferred_route) {
2924
+ let route = priv.deferred_route;
2925
+ priv.deferred_route = "";
2926
+ yui_shell_navigate(gobj, route);
2927
+ }
2816
2928
  }
2817
2929
 
2818
2930
  function overlay_dismissed(gobj, entry)
@@ -3085,6 +3197,13 @@ function ac_nav_clicked(gobj, event, kw, src)
3085
3197
  * Exception: URL-restoring action routes skip the push — see
3086
3198
  * route_restores_url. */
3087
3199
  if(gobj_read_attr(gobj, "use_hash") && !route_restores_url(gobj, route)) {
3200
+ if(gobj.priv.expected_pops > 0) {
3201
+ /* A back() of ours is in flight (an overlay closed in this
3202
+ * same turn): a push now would be undone by it, as in
3203
+ * yui_shell_navigate(). */
3204
+ defer_route(gobj, route);
3205
+ return 0;
3206
+ }
3088
3207
  let target_hash = route_to_hash(route);
3089
3208
  if(window.location.hash !== target_hash) {
3090
3209
  window.location.hash = target_hash; /* fires hashchange */
@@ -3674,6 +3793,16 @@ function yui_shell_zone(shell_gobj, zone_id)
3674
3793
  function yui_shell_navigate(shell_gobj, route, opts)
3675
3794
  {
3676
3795
  if(!(opts && opts.replace) && gobj_read_attr(shell_gobj, "use_hash")) {
3796
+ let priv = shell_gobj.priv;
3797
+ if(priv && priv.expected_pops > 0) {
3798
+ /* A back() of ours is in flight (an overlay closed in this
3799
+ * same turn, e.g. a dialog's action that closes it and then
3800
+ * navigates): a push now lands BEFORE the traversal, which
3801
+ * then runs from it and undoes it (and in Firefox lands on
3802
+ * the closed overlay's marker). Navigate once it is over. */
3803
+ defer_route(shell_gobj, route);
3804
+ return;
3805
+ }
3677
3806
  let target_hash = route_to_hash(route);
3678
3807
  if(window.location.hash !== target_hash) {
3679
3808
  /* Push a real history entry; the hashchange handler mounts. */
@@ -3025,6 +3025,17 @@ const LEGEND_STAR_MAIN_STYLE = LEGEND_GLYPH_STYLE +
3025
3025
  * outside the box is clipped by its neighbours. */
3026
3026
  const LEGEND_FOCUSED_STYLE = 'box-shadow: inset 0 0 0 2px var(--bulma-text, #2e333d);';
3027
3027
 
3028
+ /************************************************************
3029
+ * The name of a topic in the legend: schema data, never markup.
3030
+ ************************************************************/
3031
+ function legend_name_item(topic_name, is_main, hidden)
3032
+ {
3033
+ return ['span', {class: 'GRAPH_LEGEND_NAME',
3034
+ style: (is_main? LEGEND_MAIN_NAME_STYLE : LEGEND_NAME_STYLE) +
3035
+ (hidden? ' text-decoration:line-through; opacity:.6;' : '')},
3036
+ text_node(topic_name)];
3037
+ }
3038
+
3028
3039
  function refresh_legend(gobj)
3029
3040
  {
3030
3041
  let priv = gobj.priv;
@@ -3082,10 +3093,7 @@ function refresh_legend(gobj)
3082
3093
  `background:${entry.color || "#94a3b8"}; ` +
3083
3094
  `border:1px solid rgba(0,0,0,.25);` +
3084
3095
  (hidden? 'opacity:.35;' : '')}],
3085
- ['span', {class: 'GRAPH_LEGEND_NAME',
3086
- style: (is_main? LEGEND_MAIN_NAME_STYLE : LEGEND_NAME_STYLE) +
3087
- (hidden? ' text-decoration:line-through; opacity:.6;' : '')},
3088
- text_node(topic_name)], // schema data, never markup
3096
+ legend_name_item(topic_name, is_main, hidden),
3089
3097
  ['span', {class: 'GRAPH_LEGEND_COUNT',
3090
3098
  style: LEGEND_COUNT_STYLE},
3091
3099
  hidden? `${entry.total}` : `${entry.visible}/${entry.total}`]
@@ -3874,4 +3882,7 @@ function register_c_yui_treedb_graph()
3874
3882
  return create_gclass(GCLASS_NAME);
3875
3883
  }
3876
3884
 
3877
- export { register_c_yui_treedb_graph };
3885
+ export {
3886
+ register_c_yui_treedb_graph,
3887
+ legend_name_item, // exported for its test
3888
+ };
@@ -5563,4 +5563,9 @@ function register_c_yui_treedb_topic_with_form()
5563
5563
  return create_gclass(GCLASS_NAME);
5564
5564
  }
5565
5565
 
5566
- export { register_c_yui_treedb_topic_with_form };
5566
+ export {
5567
+ register_c_yui_treedb_topic_with_form,
5568
+ /* Exported for its test: an icon cell shows a name that fails the
5569
+ * check as text, never as markup (it is a value of the record). */
5570
+ icon_formatter,
5571
+ };
@@ -35,7 +35,6 @@ import {
35
35
  data_type_t,
36
36
  gclass_create,
37
37
  log_error,
38
- log_warning,
39
38
  is_gobj,
40
39
  gobj_full_name,
41
40
  gobj_short_name,
@@ -350,31 +349,19 @@ function chip_lead(icon)
350
349
  * trace dumps it), so the window travels in it as its FULL NAME,
351
350
  * which the trace can print, and the gobj is the event's src --
352
351
  * every sender is the window itself. Up to 7.26.9 the kw carried
353
- * the gobj; that is still taken, with a warning, for this release.
352
+ * the gobj; since 7.26.14 that is refused.
354
353
  ************************************************************/
355
- let warned_gobj_in_kw = false;
356
-
357
354
  function window_of(gobj, event, kw, src)
358
355
  {
359
356
  let w = kw && kw.window;
360
357
  if(is_gobj(w)) {
361
- if(!warned_gobj_in_kw) {
362
- warned_gobj_in_kw = true;
363
- log_warning(
364
- `${gobj_short_name(gobj)}: ${event} carries the window gobj ` +
365
- `in its kw: send {window: gobj_full_name(window)} from the window`
366
- );
367
- }
368
- if(w !== src) {
369
- /* Only the window speaks for itself, in either form. */
370
- log_error(
371
- `${gobj_short_name(gobj)}: ${event}: window ` +
372
- `'${gobj_full_name(w)}' is not the src of the event ` +
373
- `(${is_gobj(src) ? gobj_full_name(src) : String(src)})`
374
- );
375
- return null;
376
- }
377
- return w;
358
+ /* The gobj in the kw was accepted up to 7.26.13 (with a warning
359
+ * since 7.26.10). A kw is plain json: refused. */
360
+ log_error(
361
+ `${gobj_short_name(gobj)}: ${event} carries the window gobj in ` +
362
+ `its kw: send {window: gobj_full_name(window)} from the window`
363
+ );
364
+ return null;
378
365
  }
379
366
  if(!is_gobj(src) || gobj_full_name(src) !== w) {
380
367
  log_error(
@@ -0,0 +1,196 @@
1
+ /***********************************************************************
2
+ * data_as_text.wiring.test.js
3
+ *
4
+ * Values that come from a backend, a schema or a record are
5
+ * DATA: they are shown as text, never parsed as markup. One case
6
+ * per sink fixed in the review of 2026-10-10 (yunovatios
7
+ * REV-CLOUD.md V3.1 #1, #2, #4, #5 and V4.2): each one is fed a
8
+ * markup string and must show it, with no element created.
9
+ *
10
+ * Copyright (c) 2026, ArtGins.
11
+ * All Rights Reserved.
12
+ ***********************************************************************/
13
+ import {describe, test, expect, beforeAll} from "vitest";
14
+ import {install_dom_double} from "../test/dom_double.js";
15
+
16
+ install_dom_double();
17
+
18
+ if(typeof globalThis.ResizeObserver === "undefined") {
19
+ globalThis.ResizeObserver = class {
20
+ observe() {
21
+ }
22
+ unobserve() {
23
+ }
24
+ disconnect() {
25
+ }
26
+ };
27
+ }
28
+ if(typeof globalThis.matchMedia === "undefined") {
29
+ globalThis.matchMedia = () => ({matches: false, addEventListener() {}, removeEventListener() {}});
30
+ }
31
+
32
+ const {
33
+ SDATA, SDATA_END, data_type_t, gclass_create, gobj_write_attr,
34
+ gobj_start_up, gobj_create_yuno, gobj_create,
35
+ gobj_start, gobj_read_attr, gobj_send_event,
36
+ createElement2,
37
+ set_log_callback,
38
+ } = await import("@yuneta/gobj-js");
39
+
40
+ const EVIL = '<img src=x onerror="window.__pwned=1">';
41
+ let yuno = null;
42
+
43
+ beforeAll(async () => {
44
+ const i18next = (await import("i18next")).default;
45
+ await i18next.init({lng: "en", resources: {}});
46
+ gobj_start_up(null, null, null, null, null, null, null);
47
+ set_log_callback(() => {});
48
+ gclass_create("C_TEST_TEXT_HOST", [], [["ST_IDLE", []]], {}, 0, [SDATA_END()], {}, 0, 0, 0, 0);
49
+ gclass_create(
50
+ "C_TEST_TEXT_JSON_HOST",
51
+ [["EV_EXPAND_PATH", 0]],
52
+ [["ST_IDLE", [["EV_EXPAND_PATH", () => 0, null]]]],
53
+ {}, 0, [SDATA_END()], {}, 0, 0, 0, 0
54
+ );
55
+ gclass_create(
56
+ "C_TEST_TEXT_VIEW", [], [["ST_IDLE", []]], {
57
+ mt_create: (gobj) => {
58
+ gobj_write_attr(gobj, "$container", document.createElement("div"));
59
+ }
60
+ }, 0, [
61
+ SDATA(data_type_t.DTP_POINTER, "$container", 0, null, "view root"),
62
+ SDATA(data_type_t.DTP_POINTER, "subscriber", 0, null, "subscriber"),
63
+ SDATA_END()
64
+ ], {}, 0, 0, 0, 0
65
+ );
66
+ yuno = gobj_create_yuno("data_text_yuno", "C_TEST_TEXT_HOST", {});
67
+ gobj_start(yuno);
68
+ });
69
+
70
+ /* What a reader sees, and no element built from the data. */
71
+ function expect_text($el, text)
72
+ {
73
+ expect($el.textContent.includes(text)).toBe(true);
74
+ expect($el.querySelector("img")).toBe(null);
75
+ }
76
+
77
+ describe("data is text, not markup", () => {
78
+ test("V3.1 #1: an icon cell with a name that fails the check", async () => {
79
+ const {icon_formatter} = await import("./c_yui_treedb_topic_with_form.js");
80
+ const $cell = icon_formatter({getValue: () => EVIL});
81
+ expect_text($cell, EVIL);
82
+ });
83
+
84
+ test("V3.1 #2: the schema editor's select options and textarea value", async () => {
85
+ const {select_input, textarea_input} = await import("./c_yui_schema_editor.js");
86
+ const $select = createElement2(select_input("topic", "x", [EVIL, "ok"]));
87
+ expect_text($select, EVIL);
88
+ expect($select.querySelectorAll("option").length).toBe(2);
89
+ const $area = createElement2(textarea_input("desc", EVIL, 3, ""));
90
+ expect_text($area, EVIL);
91
+ });
92
+
93
+ test("V3.1 #4: the error of a subtree the JSON viewer could not load", async () => {
94
+ const {register_c_yui_json} = await import("./c_yui_json.js");
95
+ register_c_yui_json();
96
+ const host = gobj_create("json_text_host", "C_TEST_TEXT_JSON_HOST", {}, yuno);
97
+ gobj_start(host);
98
+ const viewer = gobj_create("json_text", "C_YUI_JSON", {view_mode: "tree"}, host);
99
+ gobj_start(viewer);
100
+ gobj_send_event(viewer, "EV_SET_JSON",
101
+ {json: {a: {__collapsed__: {size: 3, path: "a"}}}}, host);
102
+ gobj_send_event(viewer, "EV_SUBTREE_ERROR", {path: "a", error: EVIL}, host);
103
+ const $c = gobj_read_attr(viewer, "$container");
104
+ const $err = $c.querySelector(".JSON_STUB_ERR");
105
+ expect($err).not.toBe(null);
106
+ expect_text($err, EVIL);
107
+ });
108
+
109
+ test("V3.1 #5: the shell's toolbar label and dropdown label", async () => {
110
+ const {register_c_yui_shell} = await import("./c_yui_shell.js");
111
+ register_c_yui_shell();
112
+ const config = {
113
+ shell: {
114
+ zones: {top: {host: "toolbar"}, center: {host: "stage.main"}},
115
+ stages: {main: {zone: "center", default_route: "/home"}}
116
+ },
117
+ toolbar: {
118
+ zone: "top",
119
+ items: [
120
+ {id: "plain", name: EVIL,
121
+ action: {type: "event", event: "EV_TEXT_PLAIN"}},
122
+ {id: "menu", name: "menu",
123
+ action: {type: "dropdown", items: [
124
+ {id: "sub", name: EVIL,
125
+ action: {type: "event", event: "EV_TEXT_SUB"}}
126
+ ]}}
127
+ ]
128
+ },
129
+ menu: {
130
+ primary: {items: [{id: "home", route: "/home",
131
+ target: {stage: "main", gclass: "C_TEST_TEXT_VIEW", kw: {}}}]}
132
+ }
133
+ };
134
+ const shell = gobj_create("text_shell", "C_YUI_SHELL", {config: config}, yuno);
135
+ gobj_start(shell);
136
+ const $c = gobj_read_attr(shell, "$container");
137
+
138
+ const $label = $c.querySelector('[data-toolbar-item-id="plain"] .yui-toolbar-item-label');
139
+ expect($label).not.toBe(null);
140
+ expect_text($label, EVIL);
141
+
142
+ const $menu = $c.querySelector('[data-toolbar-item-id="menu"]');
143
+ expect($menu).not.toBe(null);
144
+ $menu.click();
145
+ const $sub = document.querySelector(".yui-toolbar-dropdown-label");
146
+ expect($sub).not.toBe(null);
147
+ expect_text($sub, EVIL);
148
+ });
149
+
150
+ test("V4.2: a topic name in the treedb graph legend", async () => {
151
+ const {legend_name_item} = await import("./c_yui_treedb_graph.js");
152
+ for(const [is_main, hidden] of [[false, false], [true, false], [false, true]]) {
153
+ const $name = createElement2(legend_name_item(EVIL, is_main, hidden));
154
+ expect($name.textContent).toBe(EVIL);
155
+ expect($name.querySelector("img")).toBe(null);
156
+ }
157
+ });
158
+
159
+ test("V4.2: the G6 toolbar escapes what it puts in its markup", async () => {
160
+ const {toolbar_item_html} = await import("./c_g6_nodes_tree.js");
161
+ const items = [
162
+ {readout: true, text: EVIL, title: EVIL, className: EVIL},
163
+ {id: EVIL, value: EVIL, title: EVIL},
164
+ {text: EVIL, value: "v", title: "t"},
165
+ ];
166
+ /* The DOM double builds no element out of markup, so the html is
167
+ * read here as a browser would: tags out, entities decoded. What
168
+ * the reader sees and what each attribute holds must be the
169
+ * value itself -- an unescaped value drops out of the text. */
170
+ const decode = (v) => v.replace(/&lt;/g, "<").replace(/&gt;/g, ">")
171
+ .replace(/&quot;/g, '"').replace(/&#39;/g, "'").replace(/&amp;/g, "&");
172
+ const visible = (html) => decode(html.replace(/<[^>]*>/g, ""));
173
+ const attr = (html, name) => {
174
+ const m = html.match(new RegExp(` ${name}="([^"]*)"`));
175
+ return m ? decode(m[1]) : null;
176
+ };
177
+ const read = toolbar_item_html(items[0]);
178
+ expect(visible(read)).toBe(EVIL);
179
+ expect(attr(read, "title")).toBe(EVIL);
180
+ expect(attr(read, "aria-label")).toBe(EVIL);
181
+ expect(attr(read, "class")).toBe(`g6-toolbar-readout ${EVIL}`);
182
+
183
+ const icon = toolbar_item_html(items[1]);
184
+ expect(visible(icon)).toBe("");
185
+ expect(attr(icon, "value")).toBe(EVIL);
186
+ expect(attr(icon, "title")).toBe(EVIL);
187
+ expect(attr(icon, "xlink:href")).toBe(`#${EVIL}`);
188
+
189
+ const text = toolbar_item_html(items[2]);
190
+ expect(visible(text)).toBe(EVIL);
191
+
192
+ for(const item of items) {
193
+ expect(toolbar_item_html(item).includes("<img")).toBe(false);
194
+ }
195
+ });
196
+ });
@@ -60,4 +60,43 @@ describe("C_YUI_GCLASS header", () => {
60
60
  expect($c.querySelector(".GCLASS_CURRENT").textContent).toBe(EVIL);
61
61
  expect($c.querySelector("img")).toBe(null);
62
62
  });
63
+
64
+ test("the method chips are text (V3.1 #4)", () => {
65
+ const view = gobj_create("gclass_methods_text", "C_YUI_GCLASS", {
66
+ description: {id: "C_X", gcflag: [], attrs: [], commands: [],
67
+ gclass_methods: [EVIL], internal_methods: [EVIL],
68
+ FSM: {events: [], states: {}}},
69
+ }, yuno);
70
+ gobj_start(view);
71
+ const $c = gobj_read_attr(view, "$container");
72
+ const chips = $c.querySelectorAll(".GCLASS_METHOD");
73
+ expect(chips.length).toBe(2);
74
+ for(const chip of chips) {
75
+ expect(chip.textContent).toBe(EVIL);
76
+ }
77
+ expect($c.querySelector("img")).toBe(null);
78
+ });
79
+
80
+ test("the error of the raw dump is text (V3.1 #4)", () => {
81
+ const description = {
82
+ id: "C_X", gcflag: [], attrs: [], commands: [],
83
+ gclass_methods: [], internal_methods: [],
84
+ FSM: {events: [], states: {}},
85
+ toJSON() {
86
+ /* A bare string thrown is what reaches the screen as is:
87
+ * String() of an Error starts with "Error:", never "<". */
88
+ throw EVIL;
89
+ },
90
+ };
91
+ const view = gobj_create("gclass_raw_error_text", "C_YUI_GCLASS", {
92
+ description: description, view_mode: "raw",
93
+ }, yuno);
94
+ gobj_start(view);
95
+ const $c = gobj_read_attr(view, "$container");
96
+ const $err = $c.querySelector(".GCLASS_RAW_ERROR");
97
+ expect($err).not.toBe(null);
98
+ expect($err.textContent.includes(EVIL)).toBe(true);
99
+ expect($c.querySelector("img")).toBe(null);
100
+ });
63
101
  });
102
+