remove comments
Hunter
Monday, August 31st, 2026 at 11:13 PM
238 return settle;
239 }
240
- // Collapses the compact attribution once the style names its sources, then takes
- // the button over from maplibre so a tap anywhere else can dismiss it.
241 function initAttribution() {
242 var el = map.getContainer().querySelector(".maplibregl-ctrl-attrib");
243 if (!el) { return; }
245
246 function shown() { return el.classList.contains("maplibregl-compact-show"); }
247
- // maplibre's own handler pre-flips `open` so the native <details> toggle lands
- // on the right value; we suppress both, so `open` just tracks the panel
248 function setShown(show) {
249 el.classList.toggle("maplibregl-compact-show", show);
250 if (show) { el.setAttribute("open", ""); } else { el.removeAttribute("open"); }
251 }
252
253 if (button) {
- // capture on the container beats maplibre's own listener on the button;
- // preventDefault also keeps the native <details> from double-toggling
254 el.addEventListener("click", function (e) {
255 if (!button.contains(e.target)) { return; }
256 e.preventDefault();
259 }, true);
260 }
261
- // anything else on the page dismisses it; capture on the document so a
- // stopPropagation further in (the event pins do it) can't swallow the tap
262 document.addEventListener("click", function (e) {
263 if (button && button.contains(e.target)) { return; }
264 if (shown()) { setShown(false); }