@@ -19,11 +19,13 @@ interface FeatureElement extends LeafletBase {
19
19
layer : L . LayerGroup | L . Layer ;
20
20
}
21
21
22
- const isFeatureElement = (
22
+ function isFeatureElement (
23
23
x : Node & Partial < FeatureElement >
24
- ) : x is Node & FeatureElement => x && 'feature' in x ;
24
+ ) : x is FeatureElement {
25
+ return x && ( x . tagName . startsWith ( 'LEAFLET-' ) || 'feature' in x ) ;
26
+ }
25
27
26
- function isSlot ( node : ChildNode ) : node is HTMLSLotElement {
28
+ function isSlot ( node : ChildNode ) : node is HTMLSlotElement {
27
29
return node instanceof HTMLSlotElement ;
28
30
}
29
31
@@ -364,14 +366,16 @@ export class LeafletMap extends LeafletBase {
364
366
return L . latLng ( this . latitude , this . longitude ) ;
365
367
}
366
368
367
- private get elements ( ) : ChildNode [ ] {
368
- return [ ...this . children ] . reduce (
369
- ( acc , child ) => [
370
- ...acc ,
371
- ...( isSlot ( child ) ? child . assignedElements ( ) : [ child ] ) ,
372
- ] ,
373
- [ ]
374
- ) ;
369
+ private get elements ( ) : FeatureElement [ ] {
370
+ return [ ...this . children ]
371
+ . reduce (
372
+ ( acc , child ) => [
373
+ ...acc ,
374
+ ...( isSlot ( child ) ? child . assignedElements ( ) : [ child ] ) ,
375
+ ] ,
376
+ [ ]
377
+ )
378
+ . filter ( isFeatureElement ) ;
375
379
}
376
380
377
381
_ignoreViewChange : boolean ;
@@ -400,7 +404,7 @@ export class LeafletMap extends LeafletBase {
400
404
401
405
async fitToMarkersChanged ( ) {
402
406
if ( this . map && this . fitToMarkers ) {
403
- const elements = this . elements . filter ( isFeatureElement ) ;
407
+ const { elements } = this ;
404
408
if ( ! elements . length ) return ;
405
409
await Promise . race ( [
406
410
new Promise ( r => setTimeout ( r , 100 ) ) ,
0 commit comments