diff --git a/src/components/leaflet-feature-group.ts b/src/components/leaflet-feature-group.ts index 3f59d96..7d01480 100644 --- a/src/components/leaflet-feature-group.ts +++ b/src/components/leaflet-feature-group.ts @@ -15,10 +15,10 @@ export class LeafletFeatureGroup extends HTMLElement { } disconnectedCallback() { - for (const [el, entry] of getChildren(this) ?? []) { - if (entry.type === 'popup') this.#obj?.unbindPopup(); - else if (entry.type === 'tooltip') this.#obj?.unbindTooltip(); - else if (entry.type === 'layer') this.#obj?.removeLayer(el as unknown as Layer); + for (const [el, type] of getChildren(this) ?? []) { + if (type === 'popup') this.#obj?.unbindPopup(); + else if (type === 'tooltip') this.#obj?.unbindTooltip(); + else if (type === 'layer') this.#obj?.removeLayer(el as unknown as Layer); } unregisterChildren(this); this.#obj?.remove(); diff --git a/src/components/leaflet-geojson.ts b/src/components/leaflet-geojson.ts index 84b432a..df234aa 100644 --- a/src/components/leaflet-geojson.ts +++ b/src/components/leaflet-geojson.ts @@ -37,10 +37,10 @@ export class LeafletGeoJSON extends WithProps(HTMLElement, PROPS) { } disconnectedCallback() { - for (const [el, entry] of getChildren(this) ?? []) { - if (entry.type === 'popup') this.#obj?.unbindPopup(); - else if (entry.type === 'tooltip') this.#obj?.unbindTooltip(); - else if (entry.type === 'layer') this.#obj?.removeLayer(el as unknown as Layer); + for (const [el, type] of getChildren(this) ?? []) { + if (type === 'popup') this.#obj?.unbindPopup(); + else if (type === 'tooltip') this.#obj?.unbindTooltip(); + else if (type === 'layer') this.#obj?.removeLayer(el as unknown as Layer); } unregisterChildren(this); this.#obj?.remove(); diff --git a/src/components/leaflet-layer-group.ts b/src/components/leaflet-layer-group.ts index 74c768d..3d00542 100644 --- a/src/components/leaflet-layer-group.ts +++ b/src/components/leaflet-layer-group.ts @@ -15,10 +15,10 @@ export class LeafletLayerGroup extends HTMLElement { } disconnectedCallback() { - for (const [el, entry] of getChildren(this) ?? []) { - if (entry.type === 'popup') this.#obj?.unbindPopup(); - else if (entry.type === 'tooltip') this.#obj?.unbindTooltip(); - else if (entry.type === 'layer') this.#obj?.removeLayer(el as unknown as Layer); + for (const [el, type] of getChildren(this) ?? []) { + if (type === 'popup') this.#obj?.unbindPopup(); + else if (type === 'tooltip') this.#obj?.unbindTooltip(); + else if (type === 'layer') this.#obj?.removeLayer(el as unknown as Layer); } unregisterChildren(this); this.#obj?.remove(); diff --git a/src/core/register.ts b/src/core/register.ts index d32ce38..a4a22b1 100644 --- a/src/core/register.ts +++ b/src/core/register.ts @@ -33,9 +33,7 @@ export function emitIconChanged(el: HTMLElement, icon: Icon | null | undefined) // Tracks whether a child registered as a plain layer, popup, or tooltip -- // used by the controls panel and by cleanup logic. -type ChildEntry = { - type: 'layer' | 'popup' | 'tooltip'; -}; +type ChildEntry = 'layer' | 'popup' | 'tooltip'; // Builds the event handler for a given parent layer. On each // leaflet-register event from a descendant, it checks the Leaflet type: @@ -49,15 +47,15 @@ function createChildRegisterHandler(layer: Layer, children: Map