From 1f9d837c70683709c84b80e0af109ccda4315d5d Mon Sep 17 00:00:00 2001 From: DevEnv nis2-agile Date: Tue, 25 Aug 2026 18:02:09 +0200 Subject: [PATCH] [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 (->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) --- public/organigramma.html | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/public/organigramma.html b/public/organigramma.html index a926c0e..08b17e1 100644 --- a/public/organigramma.html +++ b/public/organigramma.html @@ -167,7 +167,22 @@ v3Icons(); var root = document.querySelector('main.wrap'); if (root && window.MutationObserver) { - var mo = new MutationObserver(function () { v3Icons(); }); + // NB: createIcons() sostituisce con → è 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 }); } });