Use arrow callback (#9684)

This commit is contained in:
Simon Legner
2025-04-23 06:24:40 +02:00
committed by GitHub
parent 9f80640b8f
commit b00da86477
4 changed files with 5 additions and 11 deletions

View File

@ -62,9 +62,7 @@ export const Attribution = Control.extend({
_addAttribution(ev) {
if (ev.layer.getAttribution) {
this.addAttribution(ev.layer.getAttribution());
ev.layer.once('remove', function () {
this.removeAttribution(ev.layer.getAttribution());
}, this);
ev.layer.once('remove', () => this.removeAttribution(ev.layer.getAttribution()));
}
},

View File

@ -165,9 +165,7 @@ function removeOne(obj, type, fn, context, id) {
// @function stopPropagation(ev: DOMEvent): this
// Stop the given event from propagation to parent elements. Used inside the listener functions:
// ```js
// L.DomEvent.on(div, 'click', function (ev) {
// L.DomEvent.stopPropagation(ev);
// });
// L.DomEvent.on(div, 'click', L.DomEvent.stopPropagation);
// ```
export function stopPropagation(e) {

View File

@ -107,9 +107,7 @@ export const Layer = Evented.extend({
if (this.getEvents) {
const events = this.getEvents();
map.on(events, this);
this.once('remove', function () {
map.off(events, this);
}, this);
this.once('remove', () => map.off(events, this));
}
this.onAdd(map);

View File

@ -220,10 +220,10 @@ export const Popup = DivOverlay.extend({
closeButton.href = '#close';
closeButton.innerHTML = '<span aria-hidden="true">&#215;</span>';
DomEvent.on(closeButton, 'click', function (ev) {
DomEvent.on(closeButton, 'click', (ev) => {
DomEvent.preventDefault(ev);
this.close();
}, this);
});
}