@ -1,5 +1,5 @@
import { TileLayer } from 'leaflet' ;
import { TileLayer } from 'leaflet' ;
import { buildOptions , parseAttributeValue } from '../core/utils.js' ;
import { buildOptions , buildAttrMap, setLayerAttr , parseAttributeValue } from '../core/utils.js' ;
import { withProps } from '../core/with-props.js' ;
import { withProps } from '../core/with-props.js' ;
import { registerChildren , unregisterChildren } from '../core/register.js' ;
import { registerChildren , unregisterChildren } from '../core/register.js' ;
@ -15,9 +15,7 @@ const PROPS = {
uppercase : { kind : 'bool-on' , attr : 'uppercase' } ,
uppercase : { kind : 'bool-on' , attr : 'uppercase' } ,
} satisfies Record < string , PropDef > ;
} satisfies Record < string , PropDef > ;
const PROP_BY_ATTR = new Map < string , string > (
const PROP_BY_ATTR = buildAttrMap ( PROPS ) ;
Object . entries ( PROPS ) . map ( ( [ name , spec ] ) = > [ spec . attr , name ] ) ,
) ;
export class LeafletTileLayerWMS extends withProps ( HTMLElement , PROPS ) {
export class LeafletTileLayerWMS extends withProps ( HTMLElement , PROPS ) {
# obj? : TileLayer.WMS ;
# obj? : TileLayer.WMS ;
@ -44,13 +42,8 @@ export class LeafletTileLayerWMS extends withProps(HTMLElement, PROPS) {
} else {
} else {
const propName = PROP_BY_ATTR . get ( name ) ;
const propName = PROP_BY_ATTR . get ( name ) ;
if ( ! propName ) return ;
if ( ! propName ) return ;
const setter =
` set ${ propName . charAt ( 0 ) . toUpperCase ( ) } ${ propName . slice ( 1 ) } ` as keyof TileLayer . WMS ;
const spec = PROPS [ propName as keyof typeof PROPS ] ;
const spec = PROPS [ propName as keyof typeof PROPS ] ;
if ( typeof this . # obj [ setter ] === 'function' ) {
if ( ! setLayerAttr ( this . # obj ! , PROPS , PROP_BY_ATTR , name , val ) ) {
const value = spec . kind === 'bool-on' ? val !== null : parseAttributeValue ( val ) ;
( this . # obj [ setter ] as ( v : unknown ) = > void ) ( value ) ;
} else {
const value = spec . kind === 'bool-on' ? val !== null : parseAttributeValue ( val ) ;
const value = spec . kind === 'bool-on' ? val !== null : parseAttributeValue ( val ) ;
( this . # obj . setParams as unknown as ( params : Record < string , unknown > ) = > void ) ( {
( this . # obj . setParams as unknown as ( params : Record < string , unknown > ) = > void ) ( {
[ propName ] : value ,
[ propName ] : value ,