Skip to content

Commit

Permalink
Drop type casts related to L.DomUtil.create
Browse files Browse the repository at this point in the history
  • Loading branch information
simon04 committed Dec 26, 2024
1 parent e92025d commit 0ea1413
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions src/control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ export class GeocoderControl extends EventedControl {
*/
onAdd(map: L.Map) {
const className = 'leaflet-control-geocoder';
const container = L.DomUtil.create('div', className + ' leaflet-bar') as HTMLDivElement;
const icon = L.DomUtil.create('button', className + '-icon', container) as HTMLButtonElement;
const form = L.DomUtil.create('div', className + '-form', container) as HTMLDivElement;
const container = L.DomUtil.create('div', className + ' leaflet-bar');
const icon = L.DomUtil.create('button', className + '-icon', container);
const form = L.DomUtil.create('div', className + '-form', container);

this._map = map;
this._container = container;
Expand All @@ -179,24 +179,20 @@ export class GeocoderControl extends EventedControl {
icon.type = 'button';
icon.setAttribute('aria-label', this.options.iconLabel);

const input = (this._input = L.DomUtil.create('input', '', form) as HTMLInputElement);
const input = (this._input = L.DomUtil.create('input', '', form));
input.type = 'search';
input.value = this.options.query;
input.placeholder = this.options.placeholder;
L.DomEvent.disableClickPropagation(input);

this._errorElement = L.DomUtil.create(
'div',
className + '-form-no-error',
container
) as HTMLDivElement;
this._errorElement = L.DomUtil.create('div', className + '-form-no-error', container);
this._errorElement.innerHTML = this.options.errorMessage;

this._alts = L.DomUtil.create(
'ul',
className + '-alternatives leaflet-control-geocoder-alternatives-minimized',
container
) as HTMLUListElement;
);
L.DomEvent.disableClickPropagation(this._alts);

L.DomEvent.addListener(input, 'keydown', this._keydown, this);
Expand Down Expand Up @@ -368,10 +364,7 @@ export class GeocoderControl extends EventedControl {
private _createAlt(result: GeocodingResult, index: number) {
const li = L.DomUtil.create('li', ''),
a = L.DomUtil.create('a', '', li),
icon =
this.options.showResultIcons && result.icon
? (L.DomUtil.create('img', '', a) as HTMLImageElement)
: null,
icon = this.options.showResultIcons && result.icon ? L.DomUtil.create('img', '', a) : null,
text = result.html ? undefined : document.createTextNode(result.name),
mouseDownHandler = (e: Event) => {
// In some browsers, a click will fire on the map if the control is
Expand Down

0 comments on commit 0ea1413

Please sign in to comment.