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 }); } });