Only call add/removeInteractiveTarget for path if actually interactive

This commit is contained in:
Yohan Boniface
2024-09-19 11:21:04 +02:00
parent 8c9bd93561
commit 34217f1782

View File

@ -95,12 +95,16 @@ export const SVG = Renderer.extend({
_addPath(layer) {
if (!this._rootGroup) { this._initContainer(); }
this._rootGroup.appendChild(layer._path);
layer.addInteractiveTarget(layer._path);
if (layer.options.interactive) {
layer.addInteractiveTarget(layer._path);
}
},
_removePath(layer) {
layer._path.remove();
layer.removeInteractiveTarget(layer._path);
if (layer.options.interactive) {
layer.removeInteractiveTarget(layer._path);
}
delete this._layers[stamp(layer)];
},
@ -147,8 +151,10 @@ export const SVG = Renderer.extend({
if (options.interactive) {
path.classList.add('leaflet-interactive');
layer.addInteractiveTarget(path);
} else {
path.classList.remove('leaflet-interactive');
layer.removeInteractiveTarget(path);
}
},