From e6acb7eef6c243c6dbabd90bc235480f3b44324d Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Sat, 13 Jan 2024 19:51:49 +0100 Subject: Replace .ariaExpanded/.ariaHidden with .setAttribute(). The former appears not to work well with Firefox (the attribute is updated internally but the source doesn't change and the element remains unvisible). --- main.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'main.js') diff --git a/main.js b/main.js index d59adbf..d542434 100644 --- a/main.js +++ b/main.js @@ -175,7 +175,7 @@ const menu = document.getElementById('map-menu'); const btn = document.createElement('button'); div.appendChild(btn); btn.type = 'button'; - btn.ariaExpanded = 'false'; + btn.setAttribute('aria-expanded', 'false'); btn.title = 'Byt kartlager'; btn.classList.add('btn', 'btn-light'); @@ -185,14 +185,14 @@ const menu = document.getElementById('map-menu'); const panel = document.getElementById('layer-selection-panel'); btn.onclick = function(event) { - if (btn.ariaExpanded === 'true') { - panel.ariaHidden = 'true'; - btn.ariaExpanded = 'false'; + if (btn.getAttribute('aria-expanded') === 'true') { + panel.setAttribute('aria-hidden', 'true'); + btn.setAttribute('aria-expanded', 'false'); btn.classList.add('btn-light'); btn.classList.remove('btn-dark'); } else { - panel.ariaHidden = 'false'; - btn.ariaExpanded = 'true'; + panel.setAttribute('aria-hidden', 'false'); + btn.setAttribute('aria-expanded', 'true'); btn.classList.add('btn-dark'); btn.classList.remove('btn-light'); } @@ -246,7 +246,7 @@ const menu = document.getElementById('map-menu'); const btn = document.createElement('button'); div.appendChild(btn); btn.type = 'button'; - btn.ariaExpanded = 'false'; + btn.setAttribute('aria-expanded', 'false'); btn.title = 'Visa information'; btn.classList.add('btn', 'btn-light'); @@ -257,12 +257,12 @@ const menu = document.getElementById('map-menu'); const panel = document.getElementById('modal-info'); const modal = new Modal(panel, {}); panel.addEventListener('show.bs.modal', function() { - btn.ariaExpanded = 'true'; + btn.setAttribute('aria-expanded', 'true'); btn.classList.add('btn-dark'); btn.classList.remove('btn-light'); }); panel.addEventListener('hidden.bs.modal', function() { - btn.ariaExpanded = 'false'; + btn.setAttribute('aria-expanded', 'false'); btn.classList.add('btn-light'); btn.classList.remove('btn-dark'); }); @@ -273,7 +273,7 @@ const menu = document.getElementById('map-menu'); })(); /* we're all set, show the control container now */ -container.ariaHidden = 'false'; +container.setAttribute('aria-hidden', 'false'); document.getElementById('layer-topowebb_nedtonad').onchange = function(event) { const layer = event.target.checked ? 'topowebb_nedtonad' : 'topowebb'; -- cgit v1.2.3