From 4b14eafab0ff3ddf23846202d1607744284e3c0b Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Sun, 28 Jun 2026 10:20:48 +0200 Subject: [PATCH] Fix moveend listener leak in MapLibre AttributionControl --- app/assets/javascripts/maplibre/attribution.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/maplibre/attribution.js b/app/assets/javascripts/maplibre/attribution.js index 6d2cb03d6..a4be2d91c 100644 --- a/app/assets/javascripts/maplibre/attribution.js +++ b/app/assets/javascripts/maplibre/attribution.js @@ -8,6 +8,7 @@ OSM.MapLibre.AttributionControl = class extends maplibregl.AttributionControl { this._container = null; this._includeReportLink = Boolean(includeReportLink); this._credit = credit; + this._boundUpdateReportLink = this._updateReportLink.bind(this); } _updateAttributions() { @@ -91,7 +92,7 @@ OSM.MapLibre.AttributionControl = class extends maplibregl.AttributionControl { if (this._includeReportLink) { map.once("load", this._updateAttributions.bind(this)); - map.on("moveend", this._updateReportLink.bind(this)); + map.on("moveend", this._boundUpdateReportLink); } return super.onAdd(map); @@ -101,7 +102,7 @@ OSM.MapLibre.AttributionControl = class extends maplibregl.AttributionControl { if (!this._map) return; if (this._includeReportLink) { - this._map.off("moveend", this._updateReportLink.bind(this)); + this._map.off("moveend", this._boundUpdateReportLink); } this._map = null; super.onRemove(); -- 2.47.3