[FIX] Organigramma: MutationObserver+createIcons anti-loop (debounce+disconnect)

Secondo possibile innesco del freeze: lo script inline richiamava lucide.createIcons()
su OGNI mutazione DOM (MutationObserver subtree). Poiche' createIcons muta il DOM
(<i>->svg), poteva auto-ritriggerarsi. Ora: debounce 120ms + disconnect durante il
render + flag applying per ignorare le mutazioni auto-prodotte. HTML network-first -> live al reload.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
DevEnv nis2-agile
2026-08-25 18:02:09 +02:00
co-authored by Claude Opus 4.8
parent bfda75b292
commit 1f9d837c70
+16 -1
View File
@@ -167,7 +167,22 @@
v3Icons(); v3Icons();
var root = document.querySelector('main.wrap'); var root = document.querySelector('main.wrap');
if (root && window.MutationObserver) { if (root && window.MutationObserver) {
var mo = new MutationObserver(function () { v3Icons(); }); // NB: createIcons() sostituisce <i data-lucide> con <svg> → è esso stesso una
// mutazione DOM. Osservare "ogni mutazione" e ri-chiamare createIcons può
// auto-ritriggerarsi in loop (freeze). Quindi: debounce + DISCONNECT durante il
// render, e ignora le mutazioni prodotte da noi stessi (flag applying).
var applying = false, timer = null;
var mo = new MutationObserver(function () {
if (applying) return;
clearTimeout(timer);
timer = setTimeout(function () {
applying = true;
mo.disconnect();
v3Icons();
mo.observe(root, { childList: true, subtree: true });
applying = false;
}, 120);
});
mo.observe(root, { childList: true, subtree: true }); mo.observe(root, { childList: true, subtree: true });
} }
}); });