@yuneta/gobj-ui 7.26.12 → 7.26.14
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/README.md +16 -2
- package/dist/gobj-ui.cjs.js +101 -39
- package/dist/gobj-ui.es.js +101 -39
- package/package.json +2 -1
- package/scripts/check-markup-strings.mjs +14 -2
- package/src/c_g6_nodes_tree.js +46 -38
- package/src/c_yui_schema_editor.js +5 -1
- package/src/c_yui_shell.js +133 -11
- package/src/c_yui_treedb_graph.js +16 -5
- package/src/c_yui_treedb_topic_with_form.js +6 -1
- package/src/c_yui_window_manager.js +8 -21
- package/src/data_as_text.wiring.test.js +174 -0
- package/src/gclass_head_text.wiring.test.js +39 -0
- package/src/overlay_marker_after_back.wiring.test.js +291 -14
- package/src/window_show.wiring.test.js +5 -5
package/src/c_g6_nodes_tree.js
CHANGED
|
@@ -179,6 +179,47 @@ import {yui_shell_show_error} from "./shell_modals.js";
|
|
|
179
179
|
import {g6_event_kw} from "./g6_event_kw.js";
|
|
180
180
|
import {css_color_or_null} from "./yui_data_color.js";
|
|
181
181
|
|
|
182
|
+
/***************************************************************
|
|
183
|
+
* The markup of one toolbar item. Everything that goes into it is
|
|
184
|
+
* escaped, the read-out branch too: its text, title and value are
|
|
185
|
+
* values (a zoom figure, a translated title), never markup.
|
|
186
|
+
***************************************************************/
|
|
187
|
+
function toolbar_item_html(item)
|
|
188
|
+
{
|
|
189
|
+
if(item.separator) {
|
|
190
|
+
return `<div class="g6-toolbar-sep" aria-hidden="true"></div>`;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const extra_class = item.className ? ` ${escapeHtml(String(item.className))}` : '';
|
|
194
|
+
const title = escapeHtml(String(item.title ?? ''));
|
|
195
|
+
|
|
196
|
+
if(item.readout) {
|
|
197
|
+
return (
|
|
198
|
+
`<div class="g6-toolbar-readout${extra_class}"` +
|
|
199
|
+
` title="${title}" aria-label="${title}">` +
|
|
200
|
+
`${escapeHtml(String(item.text ?? ''))}` +
|
|
201
|
+
`</div>`
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const disabled = item.disabled ? ' disabled' : '';
|
|
206
|
+
const is_text = (item.text !== undefined);
|
|
207
|
+
const kind_class = is_text ? ' g6-toolbar-item-text' : '';
|
|
208
|
+
const body = is_text
|
|
209
|
+
? `<span class="g6-toolbar-text">${escapeHtml(String(item.text))}</span>`
|
|
210
|
+
: `<svg aria-hidden="true" focusable="false">` +
|
|
211
|
+
`<use xlink:href="#${escapeHtml(String(item.id))}"></use>` +
|
|
212
|
+
`</svg>`;
|
|
213
|
+
|
|
214
|
+
return (
|
|
215
|
+
`<div class="g6-toolbar-item${kind_class}${extra_class}"` +
|
|
216
|
+
` value="${escapeHtml(String(item.value))}" title="${title}"` +
|
|
217
|
+
` aria-label="${title}"${disabled}>` +
|
|
218
|
+
`${body}` +
|
|
219
|
+
`</div>`
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
182
223
|
/***************************************************************
|
|
183
224
|
* YuiToolbar — G6 Toolbar subclass that adds per-item className
|
|
184
225
|
* and disabled support, plus three item kinds G6 does not have.
|
|
@@ -208,43 +249,7 @@ class YuiToolbar extends Toolbar
|
|
|
208
249
|
async getDOMContent()
|
|
209
250
|
{
|
|
210
251
|
const items = await this.options.getItems();
|
|
211
|
-
return items.map((
|
|
212
|
-
if(item.separator) {
|
|
213
|
-
return `<div class="g6-toolbar-sep" aria-hidden="true"></div>`;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
/* Everything that goes into this markup is escaped, the
|
|
217
|
-
* read-out branch too: its text, title and value are values
|
|
218
|
-
* (a zoom figure, a translated title), never markup. */
|
|
219
|
-
const extra_class = item.className ? ` ${escapeHtml(String(item.className))}` : '';
|
|
220
|
-
const title = escapeHtml(String(item.title ?? ''));
|
|
221
|
-
|
|
222
|
-
if(item.readout) {
|
|
223
|
-
return (
|
|
224
|
-
`<div class="g6-toolbar-readout${extra_class}"` +
|
|
225
|
-
` title="${title}" aria-label="${title}">` +
|
|
226
|
-
`${escapeHtml(String(item.text ?? ''))}` +
|
|
227
|
-
`</div>`
|
|
228
|
-
);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
const disabled = item.disabled ? ' disabled' : '';
|
|
232
|
-
const is_text = (item.text !== undefined);
|
|
233
|
-
const kind_class = is_text ? ' g6-toolbar-item-text' : '';
|
|
234
|
-
const body = is_text
|
|
235
|
-
? `<span class="g6-toolbar-text">${escapeHtml(String(item.text))}</span>`
|
|
236
|
-
: `<svg aria-hidden="true" focusable="false">` +
|
|
237
|
-
`<use xlink:href="#${escapeHtml(String(item.id))}"></use>` +
|
|
238
|
-
`</svg>`;
|
|
239
|
-
|
|
240
|
-
return (
|
|
241
|
-
`<div class="g6-toolbar-item${kind_class}${extra_class}"` +
|
|
242
|
-
` value="${escapeHtml(String(item.value))}" title="${title}"` +
|
|
243
|
-
` aria-label="${title}"${disabled}>` +
|
|
244
|
-
`${body}` +
|
|
245
|
-
`</div>`
|
|
246
|
-
);
|
|
247
|
-
}).join('');
|
|
252
|
+
return items.map(toolbar_item_html).join('');
|
|
248
253
|
}
|
|
249
254
|
}
|
|
250
255
|
register(ExtensionCategory.PLUGIN, 'yui-toolbar', YuiToolbar);
|
|
@@ -12431,4 +12436,7 @@ function register_c_g6_nodes_tree()
|
|
|
12431
12436
|
return create_gclass(GCLASS_NAME);
|
|
12432
12437
|
}
|
|
12433
12438
|
|
|
12434
|
-
export {
|
|
12439
|
+
export {
|
|
12440
|
+
register_c_g6_nodes_tree,
|
|
12441
|
+
toolbar_item_html, // exported for its test
|
|
12442
|
+
};
|
|
@@ -4823,5 +4823,9 @@ export {
|
|
|
4823
4823
|
register_c_yui_schema_editor,
|
|
4824
4824
|
/* Exported for its test: the rule that decides whether a topic still
|
|
4825
4825
|
* owes a version bump, which is asked in two places. */
|
|
4826
|
-
topic_is_draft
|
|
4826
|
+
topic_is_draft,
|
|
4827
|
+
/* Exported for their test: the options and the value of a form
|
|
4828
|
+
* control are names from the schema, data, never markup. */
|
|
4829
|
+
select_input,
|
|
4830
|
+
textarea_input,
|
|
4827
4831
|
};
|
package/src/c_yui_shell.js
CHANGED
|
@@ -164,6 +164,22 @@ let PRIVATE_DATA = {
|
|
|
164
164
|
/* Overlays registered while one of those history.back() calls is
|
|
165
165
|
* still in flight: their marker is pushed once it has landed. */
|
|
166
166
|
pending_markers: [],
|
|
167
|
+
/* The hash the shell last saw, to tell a traversal that moved it
|
|
168
|
+
* (a hashchange is queued behind its popstate) from one that did
|
|
169
|
+
* not. */
|
|
170
|
+
last_hash: "",
|
|
171
|
+
/* The waiting markers are pushed by the queued hashchange, after
|
|
172
|
+
* its navigation, not by the popstate that dropped our back(). */
|
|
173
|
+
markers_after_hashchange: false,
|
|
174
|
+
/* A position (hash) to put back when our back() lands under a
|
|
175
|
+
* marker a replace navigation had moved, and the hashchange of
|
|
176
|
+
* that landing, which must not navigate. */
|
|
177
|
+
restore_hash: "",
|
|
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: "",
|
|
167
183
|
popstate_handler: null,
|
|
168
184
|
/* Avatar item support — every toolbar item with type:"avatar"
|
|
169
185
|
* registers its <span> here so refresh_avatars() can repaint
|
|
@@ -265,19 +281,37 @@ function mt_start(gobj)
|
|
|
265
281
|
preinstantiate_eager_views(gobj);
|
|
266
282
|
|
|
267
283
|
if(gobj_read_attr(gobj, "use_hash")) {
|
|
284
|
+
priv.last_hash = window.location.hash;
|
|
268
285
|
priv.hash_handler = () => {
|
|
269
286
|
let p = gobj.priv;
|
|
270
|
-
|
|
271
|
-
|
|
287
|
+
if(!p) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
let markers_now = p.markers_after_hashchange;
|
|
291
|
+
p.markers_after_hashchange = false;
|
|
292
|
+
if(p.skip_hash && window.location.hash === p.skip_hash) {
|
|
293
|
+
/* The hashchange of an expected landing whose position
|
|
294
|
+
* was put back (see on_traversal): the route did not
|
|
295
|
+
* change, there is nothing to navigate to. */
|
|
296
|
+
p.skip_hash = "";
|
|
297
|
+
p.last_hash = window.location.hash;
|
|
298
|
+
if(markers_now) {
|
|
299
|
+
push_pending_markers(gobj);
|
|
300
|
+
}
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
p.skip_hash = "";
|
|
304
|
+
if(p.expected_pops > 0 &&
|
|
272
305
|
window.location.hash !== p.expected_pop_hash) {
|
|
273
306
|
drop_expected_pops(gobj); // a back() of ours never landed
|
|
274
|
-
|
|
307
|
+
markers_now = true;
|
|
275
308
|
}
|
|
276
309
|
let route = hash_to_route(window.location.hash);
|
|
277
310
|
if(!empty_string(route)) {
|
|
278
311
|
navigate_to(gobj, route);
|
|
279
312
|
}
|
|
280
|
-
|
|
313
|
+
p.last_hash = window.location.hash;
|
|
314
|
+
if(markers_now) {
|
|
281
315
|
/* After the navigation: an overlay it drained gets no
|
|
282
316
|
* marker, a kept one gets it on the hash it now lives on. */
|
|
283
317
|
push_pending_markers(gobj);
|
|
@@ -295,6 +329,10 @@ function mt_start(gobj)
|
|
|
295
329
|
if(!p) {
|
|
296
330
|
return;
|
|
297
331
|
}
|
|
332
|
+
/* A traversal that moved the hash is followed by a
|
|
333
|
+
* hashchange, QUEUED: it runs after this handler, and it is
|
|
334
|
+
* the one that navigates (and drains). */
|
|
335
|
+
let hash_moved = window.location.hash !== p.last_hash;
|
|
298
336
|
if(p.expected_pops > 0 &&
|
|
299
337
|
window.location.hash !== p.expected_pop_hash) {
|
|
300
338
|
/* Not the landing of ours: it was dropped. Whatever
|
|
@@ -302,13 +340,24 @@ function mt_start(gobj)
|
|
|
302
340
|
* the overlays that waited get their markers AFTER it:
|
|
303
341
|
* pushed first, the waiting top had a marker the
|
|
304
342
|
* traversal then took as "stepped off" -- it was closed
|
|
305
|
-
* and its marker left orphaned.
|
|
343
|
+
* and its marker left orphaned. When the hash moved,
|
|
344
|
+
* "after it" is after the hashchange's navigation: a
|
|
345
|
+
* marker pushed here for an overlay that navigation then
|
|
346
|
+
* drains is left orphaned too. */
|
|
306
347
|
drop_expected_pops(gobj);
|
|
307
348
|
on_traversal(ev);
|
|
308
|
-
|
|
349
|
+
if(hash_moved) {
|
|
350
|
+
p.markers_after_hashchange = true;
|
|
351
|
+
} else {
|
|
352
|
+
push_pending_markers(gobj);
|
|
353
|
+
}
|
|
354
|
+
p.last_hash = window.location.hash;
|
|
309
355
|
return;
|
|
310
356
|
}
|
|
311
357
|
on_traversal(ev);
|
|
358
|
+
if(!p.skip_hash) {
|
|
359
|
+
p.last_hash = window.location.hash;
|
|
360
|
+
}
|
|
312
361
|
};
|
|
313
362
|
let on_traversal = (ev) => {
|
|
314
363
|
let p = gobj.priv;
|
|
@@ -317,6 +366,21 @@ function mt_start(gobj)
|
|
|
317
366
|
* overlay — the teardown already happened. */
|
|
318
367
|
p.expected_pops--;
|
|
319
368
|
if(p.expected_pops === 0) {
|
|
369
|
+
if(p.restore_hash && p.restore_hash !== window.location.hash) {
|
|
370
|
+
/* The marker had moved to another hash (a replace
|
|
371
|
+
* navigation wrote the view's position on it) and
|
|
372
|
+
* the back() landed on the entry under it, on the
|
|
373
|
+
* old one: put the position back, and let its
|
|
374
|
+
* hashchange pass -- re-navigating would lose it. */
|
|
375
|
+
try {
|
|
376
|
+
window.history.replaceState(window.history.state, "", p.restore_hash);
|
|
377
|
+
p.skip_hash = p.restore_hash;
|
|
378
|
+
p.last_hash = p.restore_hash;
|
|
379
|
+
} catch(e) {
|
|
380
|
+
log_warning(`C_YUI_SHELL: restoring '${p.restore_hash}' failed: ${e}`);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
p.restore_hash = "";
|
|
320
384
|
push_pending_markers(gobj);
|
|
321
385
|
}
|
|
322
386
|
return;
|
|
@@ -325,8 +389,8 @@ function mt_start(gobj)
|
|
|
325
389
|
return;
|
|
326
390
|
}
|
|
327
391
|
let top = p.overlay_stack[p.overlay_stack.length - 1];
|
|
328
|
-
if(top.marker_pending) {
|
|
329
|
-
/* It has no marker yet: no traversal can step off it. */
|
|
392
|
+
if(top.marker_pending || top.no_marker) {
|
|
393
|
+
/* It has no marker (yet): no traversal can step off it. */
|
|
330
394
|
return;
|
|
331
395
|
}
|
|
332
396
|
/* Did this traversal step OFF the top overlay's marker?
|
|
@@ -346,7 +410,13 @@ function mt_start(gobj)
|
|
|
346
410
|
* a `stay` modal's marker legitimately lives on a hash that
|
|
347
411
|
* is NOT the resting one, and matching on the resting route
|
|
348
412
|
* left Back unable to close it. */
|
|
349
|
-
if(window.location.hash !== top.hash
|
|
413
|
+
if(window.location.hash !== top.hash &&
|
|
414
|
+
window.location.hash !== top.below_hash) {
|
|
415
|
+
/* Neither the marker's own hash nor the hash of the
|
|
416
|
+
* entry under it: a route traversal. (Under it: a
|
|
417
|
+
* replace navigation moved the marker's hash after it
|
|
418
|
+
* was pushed, and stepping off it lands on the entry
|
|
419
|
+
* below, on the hash it had.) */
|
|
350
420
|
return;
|
|
351
421
|
}
|
|
352
422
|
/* Which entry did it land ON? Markers ({__yui_overlay__:
|
|
@@ -363,12 +433,34 @@ function mt_start(gobj)
|
|
|
363
433
|
if(st && st.__yui_overlay__ === top.id) {
|
|
364
434
|
return;
|
|
365
435
|
}
|
|
436
|
+
if(st && st.__yui_overlay__ > top.id &&
|
|
437
|
+
!p.overlay_stack.some(e => e.id === st.__yui_overlay__)) {
|
|
438
|
+
/* A dead marker NEWER than the top: only Forward reaches
|
|
439
|
+
* it (an overlay closed by its button above this one).
|
|
440
|
+
* It is not a step off the top's marker. */
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
366
443
|
p.overlay_stack.pop();
|
|
367
444
|
try {
|
|
368
445
|
top.close();
|
|
369
446
|
} catch(e) {
|
|
370
447
|
log_warning(`C_YUI_SHELL: overlay close on Back failed: ${e}`);
|
|
371
448
|
}
|
|
449
|
+
if(typeof top.below_hash === "string" && top.hash !== top.below_hash &&
|
|
450
|
+
window.location.hash === top.below_hash) {
|
|
451
|
+
/* A replace navigation had written the view's position
|
|
452
|
+
* on the marker, and stepping off it landed on the entry
|
|
453
|
+
* under it, on the old hash: put the position back, and
|
|
454
|
+
* let the hashchange of this landing pass -- Back closed
|
|
455
|
+
* the panel, it did not move the view. */
|
|
456
|
+
try {
|
|
457
|
+
window.history.replaceState(window.history.state, "", top.hash);
|
|
458
|
+
p.skip_hash = top.hash;
|
|
459
|
+
p.last_hash = top.hash;
|
|
460
|
+
} catch(e) {
|
|
461
|
+
log_warning(`C_YUI_SHELL: restoring '${top.hash}' failed: ${e}`);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
372
464
|
};
|
|
373
465
|
window.addEventListener("popstate", priv.popstate_handler);
|
|
374
466
|
}
|
|
@@ -436,10 +528,20 @@ function mt_stop(gobj)
|
|
|
436
528
|
window.removeEventListener("popstate", priv.popstate_handler);
|
|
437
529
|
priv.popstate_handler = null;
|
|
438
530
|
}
|
|
439
|
-
/* Nothing listens for the landings any more.
|
|
531
|
+
/* Nothing listens for the landings any more. An overlay that
|
|
532
|
+
* waited for one gets no marker: it says so, so neither a later
|
|
533
|
+
* dismissal retires one nor a traversal waits for it. */
|
|
534
|
+
for(let entry of priv.pending_markers) {
|
|
535
|
+
entry.marker_pending = false;
|
|
536
|
+
entry.no_marker = true;
|
|
537
|
+
}
|
|
440
538
|
priv.expected_pops = 0;
|
|
441
539
|
priv.expected_pop_hash = "";
|
|
442
540
|
priv.pending_markers = [];
|
|
541
|
+
priv.markers_after_hashchange = false;
|
|
542
|
+
priv.restore_hash = "";
|
|
543
|
+
priv.skip_hash = "";
|
|
544
|
+
priv.deferred_route = "";
|
|
443
545
|
if(priv.keydown_handler) {
|
|
444
546
|
window.removeEventListener("keydown", priv.keydown_handler);
|
|
445
547
|
priv.keydown_handler = null;
|
|
@@ -1553,6 +1655,7 @@ function navigate_to(gobj, route, depth, no_drain)
|
|
|
1553
1655
|
* its Back/dismiss bookkeeping. */
|
|
1554
1656
|
try {
|
|
1555
1657
|
window.history.replaceState(window.history.state, "", target_hash);
|
|
1658
|
+
priv.last_hash = target_hash;
|
|
1556
1659
|
/* This rewrote the hash of the CURRENT entry. When that
|
|
1557
1660
|
* entry is a live marker (a replace-navigation issued
|
|
1558
1661
|
* with an overlay open), its recorded hash just went
|
|
@@ -2730,6 +2833,11 @@ function push_pending_markers(gobj)
|
|
|
2730
2833
|
entry.hash = window.location.hash;
|
|
2731
2834
|
push_overlay_marker(gobj, entry); // Error already logged
|
|
2732
2835
|
}
|
|
2836
|
+
if(priv.deferred_route) {
|
|
2837
|
+
let route = priv.deferred_route;
|
|
2838
|
+
priv.deferred_route = "";
|
|
2839
|
+
yui_shell_navigate(gobj, route);
|
|
2840
|
+
}
|
|
2733
2841
|
}
|
|
2734
2842
|
|
|
2735
2843
|
function overlay_dismissed(gobj, entry)
|
|
@@ -2748,7 +2856,7 @@ function overlay_dismissed(gobj, entry)
|
|
|
2748
2856
|
return;
|
|
2749
2857
|
}
|
|
2750
2858
|
priv.overlay_stack.splice(idx, 1);
|
|
2751
|
-
if(entry.marker_pending) {
|
|
2859
|
+
if(entry.marker_pending || entry.no_marker) {
|
|
2752
2860
|
/* Its marker was never pushed: there is nothing to retire. */
|
|
2753
2861
|
return;
|
|
2754
2862
|
}
|
|
@@ -2768,6 +2876,10 @@ function overlay_dismissed(gobj, entry)
|
|
|
2768
2876
|
priv.expected_pops++;
|
|
2769
2877
|
priv.expected_pop_hash = (typeof entry.below_hash === "string")?
|
|
2770
2878
|
entry.below_hash : window.location.hash;
|
|
2879
|
+
/* A position written on the marker by a replace navigation is
|
|
2880
|
+
* put back once the back() lands under it (on_traversal). */
|
|
2881
|
+
priv.restore_hash = (window.location.hash !== priv.expected_pop_hash)?
|
|
2882
|
+
window.location.hash : "";
|
|
2771
2883
|
try {
|
|
2772
2884
|
window.history.back();
|
|
2773
2885
|
} catch(e) {
|
|
@@ -3587,6 +3699,16 @@ function yui_shell_zone(shell_gobj, zone_id)
|
|
|
3587
3699
|
function yui_shell_navigate(shell_gobj, route, opts)
|
|
3588
3700
|
{
|
|
3589
3701
|
if(!(opts && opts.replace) && gobj_read_attr(shell_gobj, "use_hash")) {
|
|
3702
|
+
let priv = shell_gobj.priv;
|
|
3703
|
+
if(priv && priv.expected_pops > 0) {
|
|
3704
|
+
/* A back() of ours is in flight (an overlay closed in this
|
|
3705
|
+
* same turn, e.g. a dialog's action that closes it and then
|
|
3706
|
+
* navigates): a push now lands BEFORE the traversal, which
|
|
3707
|
+
* then runs from it and undoes it (and in Firefox lands on
|
|
3708
|
+
* the closed overlay's marker). Navigate once it is over. */
|
|
3709
|
+
priv.deferred_route = route;
|
|
3710
|
+
return;
|
|
3711
|
+
}
|
|
3590
3712
|
let target_hash = route_to_hash(route);
|
|
3591
3713
|
if(window.location.hash !== target_hash) {
|
|
3592
3714
|
/* 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
|
-
|
|
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 {
|
|
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 {
|
|
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
|
|
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
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
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,174 @@
|
|
|
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
|
+
for(const item of items) {
|
|
167
|
+
const html = toolbar_item_html(item);
|
|
168
|
+
expect(html.includes("<img")).toBe(false);
|
|
169
|
+
const $box = document.createElement("div");
|
|
170
|
+
$box.innerHTML = html;
|
|
171
|
+
expect($box.querySelector("img")).toBe(null);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
});
|