fix(theme): guard nav-state.js against duplicate toggle listeners
This commit is contained in:
@@ -1,10 +1,14 @@
|
|||||||
// ZB.MOM.WW.Theme nav-state.js — persists <details data-nav-key> open/closed
|
// ZB.MOM.WW.Theme nav-state.js — persists <details data-nav-key> open/closed
|
||||||
// state in localStorage so NavRailSection expand state survives navigation and
|
// state in localStorage so NavRailSection expand state survives navigation and
|
||||||
// reloads. Pure client-side; works with static Blazor SSR. Keyed per section.
|
// reloads. Pure client-side; works with static Blazor SSR. Keyed per section.
|
||||||
|
// localStorage keys are prefixed with "zbnav:" to avoid collisions.
|
||||||
(function () {
|
(function () {
|
||||||
var PREFIX = "zbnav:";
|
var PREFIX = "zbnav:";
|
||||||
|
var INIT_ATTR = "data-zbnav-initialized";
|
||||||
function apply() {
|
function apply() {
|
||||||
document.querySelectorAll("details.rail-section[data-nav-key]").forEach(function (el) {
|
document.querySelectorAll("details.rail-section[data-nav-key]").forEach(function (el) {
|
||||||
|
if (el.hasAttribute(INIT_ATTR)) return; // already wired — avoid duplicate listeners
|
||||||
|
el.setAttribute(INIT_ATTR, "");
|
||||||
var key = PREFIX + el.getAttribute("data-nav-key");
|
var key = PREFIX + el.getAttribute("data-nav-key");
|
||||||
var saved = null;
|
var saved = null;
|
||||||
try { saved = window.localStorage.getItem(key); } catch (e) { return; }
|
try { saved = window.localStorage.getItem(key); } catch (e) { return; }
|
||||||
|
|||||||
Reference in New Issue
Block a user