@ -113,13 +113,13 @@ export default class LeafletMap extends TypedBase {
Object . defineProperty ( LeafletMap . prototype , propName , {
Object . defineProperty ( LeafletMap . prototype , propName , {
get ( this : LeafletMap ) {
get ( this : LeafletMap ) {
const val = spec . mapGet && this . # map ? spec . mapGet ( this . # map ) : undefined ;
const val = spec . mapGet && this . # map ? spec . mapGet ( this . # map ) : undefined ;
return val !== undefined ? val : Number ( this . getAttribute ( spec . attr ) ? ? spec . default ) ;
return val !== undefined ? val : + ( this . getAttribute ( spec . attr ) ? ? spec . default ) ;
} ,
} ,
set ( this : LeafletMap , v : number ) {
set ( this : LeafletMap , v : number ) {
if ( spec . event ) {
if ( spec . event ) {
this . # syncAttr ( spec . attr , String ( v ) ) ;
this . # syncAttr ( spec . attr , ` ${ v } ` ) ;
} else {
} else {
this . setAttribute ( spec . attr , String ( v ) ) ;
this . setAttribute ( spec . attr , ` ${ v } ` ) ;
}
}
} ,
} ,
configurable : true ,
configurable : true ,
@ -166,9 +166,9 @@ export default class LeafletMap extends TypedBase {
// Read view-state from attributes directly — the getters call getCenter()/getZoom()
// Read view-state from attributes directly — the getters call getCenter()/getZoom()
// which throw if invoked before setView(), so we can't use them here.
// which throw if invoked before setView(), so we can't use them here.
const lat = Number ( this . getAttribute ( 'lat' ) ? ? 0 ) ;
const lat = + ( this . getAttribute ( 'lat' ) ? ? 0 ) ;
const lng = Number ( this . getAttribute ( 'lng' ) ? ? 0 ) ;
const lng = + ( this . getAttribute ( 'lng' ) ? ? 0 ) ;
const zoom = Number ( this . getAttribute ( 'zoom' ) ? ? 2 ) ;
const zoom = + ( this . getAttribute ( 'zoom' ) ? ? 2 ) ;
// Assign #map only after setView so the getters' `this.#map` guard is
// Assign #map only after setView so the getters' `this.#map` guard is
// equivalent to "map is ready" — getCenter()/getZoom() throw before setView.
// equivalent to "map is ready" — getCenter()/getZoom() throw before setView.
@ -193,7 +193,7 @@ export default class LeafletMap extends TypedBase {
for ( const s of specs ) {
for ( const s of specs ) {
if ( this . # map && s . mapGet ) {
if ( this . # map && s . mapGet ) {
const v = s . mapGet ( this . # map ) ;
const v = s . mapGet ( this . # map ) ;
if ( v !== undefined ) this . # syncAttr ( s . attr , String ( v ) ) ;
if ( v !== undefined ) this . # syncAttr ( s . attr , ` ${ v } ` ) ;
}
}
}
}
} ;
} ;
@ -233,7 +233,7 @@ export default class LeafletMap extends TypedBase {
if ( ! propName ) return ;
if ( ! propName ) return ;
const spec = PROPS [ propName ] as PropDef ;
const spec = PROPS [ propName ] as PropDef ;
if ( spec . kind === 'num' ) {
if ( spec . kind === 'num' ) {
if ( spec . mapSet && newValue !== null ) spec . mapSet ( this . # map , Number ( newValue ) ) ;
if ( spec . mapSet && newValue !== null ) spec . mapSet ( this . # map , + newValue ) ;
} else if ( spec . kind === 'bool-off' ) {
} else if ( spec . kind === 'bool-off' ) {
spec . mapSet ? . ( this . # map , newValue === null ) ;
spec . mapSet ? . ( this . # map , newValue === null ) ;
}
}
@ -292,7 +292,7 @@ export default class LeafletMap extends TypedBase {
if ( spec . kind === 'num' ) {
if ( spec . kind === 'num' ) {
if ( spec . viewState ) continue ;
if ( spec . viewState ) continue ;
const v = this . getAttribute ( spec . attr ) ;
const v = this . getAttribute ( spec . attr ) ;
if ( v !== null ) o [ propName ] = Number ( v ) ;
if ( v !== null ) o [ propName ] = + v ;
} else if ( spec . kind === 'bool-off' ) {
} else if ( spec . kind === 'bool-off' ) {
if ( this . hasAttribute ( spec . attr ) ) o [ propName ] = false ;
if ( this . hasAttribute ( spec . attr ) ) o [ propName ] = false ;
} else {
} else {