Fix boolean and nullable attribute bindings (#19432)

This commit is contained in:
Steve Repsher 2024-01-17 06:45:21 -05:00 committed by GitHub
parent d1478567f0
commit 58c4bf081b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 26 additions and 26 deletions

View File

@ -59,7 +59,7 @@ export class DemoHaBarButton extends LitElement {
<ha-control-button <ha-control-button
class=${ifDefined(btn.class)} class=${ifDefined(btn.class)}
label=${ifDefined(btn.label)} label=${ifDefined(btn.label)}
disabled=${ifDefined(btn.disabled)} ?disabled=${btn.disabled}
> >
<ha-svg-icon .path=${btn.icon || mdiLightbulb}></ha-svg-icon> <ha-svg-icon .path=${btn.icon || mdiLightbulb}></ha-svg-icon>
</ha-control-button> </ha-control-button>

View File

@ -135,7 +135,7 @@ export class DemoHaControlSelect extends LitElement {
class=${ifDefined(config.class)} class=${ifDefined(config.class)}
@value-changed=${this.handleValueChanged} @value-changed=${this.handleValueChanged}
aria-labelledby=${id} aria-labelledby=${id}
disabled=${ifDefined(config.disabled)} ?disabled=${config.disabled}
> >
</ha-control-select> </ha-control-select>
</div> </div>
@ -156,7 +156,7 @@ export class DemoHaControlSelect extends LitElement {
class=${ifDefined(config.class)} class=${ifDefined(config.class)}
@value-changed=${this.handleValueChanged} @value-changed=${this.handleValueChanged}
aria-labelledby=${id} aria-labelledby=${id}
disabled=${ifDefined(config.disabled)} ?disabled=${config.disabled}
> >
</ha-control-select> </ha-control-select>
`; `;

View File

@ -63,8 +63,8 @@ export class DemoHaControlSwitch extends LitElement {
.pathOn=${mdiLightbulb} .pathOn=${mdiLightbulb}
.pathOff=${mdiLightbulbOff} .pathOff=${mdiLightbulbOff}
aria-labelledby=${id} aria-labelledby=${id}
disabled=${ifDefined(config.disabled)} ?disabled=${config.disabled}
reversed=${ifDefined(config.reversed)} ?reversed=${config.reversed}
> >
</ha-control-switch> </ha-control-switch>
</div> </div>
@ -86,8 +86,8 @@ export class DemoHaControlSwitch extends LitElement {
aria-label=${label} aria-label=${label}
.pathOn=${mdiGarageOpen} .pathOn=${mdiGarageOpen}
.pathOff=${mdiGarage} .pathOff=${mdiGarage}
disabled=${ifDefined(config.disabled)} ?disabled=${config.disabled}
reversed=${ifDefined(config.reversed)} ?reversed=${config.reversed}
> >
</ha-control-switch> </ha-control-switch>
`; `;

View File

@ -300,7 +300,7 @@ export class HaDataTable extends LitElement {
}; };
return html` return html`
<div <div
aria-label=${column.label} aria-label=${ifDefined(column.label)}
class="mdc-data-table__header-cell ${classMap(classes)}" class="mdc-data-table__header-cell ${classMap(classes)}"
style=${column.width style=${column.width
? styleMap({ ? styleMap({

View File

@ -147,11 +147,11 @@ export class HaControlNumberButton extends LitElement {
id="input" id="input"
class="value" class="value"
role="spinbutton" role="spinbutton"
.tabIndex=${this.disabled ? "-1" : "0"} tabindex=${this.disabled ? "-1" : "0"}
aria-valuenow=${this.value} aria-valuenow=${ifDefined(this.value)}
aria-valuetext=${`${value}${unit}`} aria-valuetext=${`${value}${unit}`}
aria-valuemin=${this.min} aria-valuemin=${ifDefined(this.min)}
aria-valuemax=${this.max} aria-valuemax=${ifDefined(this.max)}
aria-label=${ifDefined(this.label)} aria-label=${ifDefined(this.label)}
?disabled=${this.disabled} ?disabled=${this.disabled}
@keydown=${this._handleKeyDown} @keydown=${this._handleKeyDown}
@ -170,7 +170,7 @@ export class HaControlNumberButton extends LitElement {
.disabled=${this.disabled || .disabled=${this.disabled ||
(this.min != null && this._value <= this.min)} (this.min != null && this._value <= this.min)}
> >
<ha-svg-icon aria-hidden .path=${mdiMinus}></ha-svg-icon> <ha-svg-icon .path=${mdiMinus}></ha-svg-icon>
</button> </button>
<button <button
class="button plus" class="button plus"
@ -181,7 +181,7 @@ export class HaControlNumberButton extends LitElement {
.disabled=${this.disabled || .disabled=${this.disabled ||
(this.max != null && this._value >= this.max)} (this.max != null && this._value >= this.max)}
> >
<ha-svg-icon aria-hidden .path=${mdiPlus}></ha-svg-icon> <ha-svg-icon .path=${mdiPlus}></ha-svg-icon>
</button> </button>
</div> </div>
`; `;

View File

@ -8,24 +8,25 @@ import {
addMonths, addMonths,
addYears, addYears,
endOfDay, endOfDay,
endOfWeek,
endOfMonth, endOfMonth,
endOfWeek,
endOfYear, endOfYear,
startOfDay, startOfDay,
startOfWeek,
startOfMonth, startOfMonth,
startOfWeek,
startOfYear, startOfYear,
} from "date-fns"; } from "date-fns";
import { import {
css,
CSSResultGroup, CSSResultGroup,
html,
LitElement, LitElement,
nothing,
PropertyValues, PropertyValues,
TemplateResult, TemplateResult,
css,
html,
nothing,
} from "lit"; } from "lit";
import { customElement, property, state } from "lit/decorators"; import { customElement, property, state } from "lit/decorators";
import { ifDefined } from "lit/directives/if-defined";
import { calcDate } from "../common/datetime/calc_date"; import { calcDate } from "../common/datetime/calc_date";
import { firstWeekdayIndex } from "../common/datetime/first_weekday"; import { firstWeekdayIndex } from "../common/datetime/first_weekday";
import { formatDate } from "../common/datetime/format_date"; import { formatDate } from "../common/datetime/format_date";
@ -34,9 +35,9 @@ import { useAmPm } from "../common/datetime/use_am_pm";
import { computeRTLDirection } from "../common/util/compute_rtl"; import { computeRTLDirection } from "../common/util/compute_rtl";
import { HomeAssistant } from "../types"; import { HomeAssistant } from "../types";
import "./date-range-picker"; import "./date-range-picker";
import "./ha-icon-button";
import "./ha-svg-icon"; import "./ha-svg-icon";
import "./ha-textfield"; import "./ha-textfield";
import "./ha-icon-button";
export interface DateRangePickerRanges { export interface DateRangePickerRanges {
[key: string]: [Date, Date]; [key: string]: [Date, Date];
@ -250,8 +251,9 @@ export class HaDateRangePicker extends LitElement {
start-date=${this.startDate.toISOString()} start-date=${this.startDate.toISOString()}
end-date=${this.endDate.toISOString()} end-date=${this.endDate.toISOString()}
?ranges=${this.ranges !== false} ?ranges=${this.ranges !== false}
opening-direction=${this.openingDirection || opening-direction=${ifDefined(
this._calcedOpeningDirection} this.openingDirection || this._calcedOpeningDirection
)}
first-day=${firstWeekdayIndex(this.hass.locale)} first-day=${firstWeekdayIndex(this.hass.locale)}
language=${this.hass.locale.language} language=${this.hass.locale.language}
> >

View File

@ -580,7 +580,7 @@ class DialogAddAutomationElement extends LitElement implements HassDialog {
: html`<img : html`<img
alt="" alt=""
slot="start" slot="start"
src=${item.image} src=${item.image!}
crossorigin="anonymous" crossorigin="anonymous"
referrerpolicy="no-referrer" referrerpolicy="no-referrer"
/>`} />`}

View File

@ -68,7 +68,7 @@ export class HuiPictureHeaderFooter
return html` return html`
<img <img
alt=${this._config!.alt_text} alt=${ifDefined(this._config?.alt_text)}
@action=${this._handleAction} @action=${this._handleAction}
.actionHandler=${actionHandler({ .actionHandler=${actionHandler({
hasHold: hasAction(this._config!.hold_action), hasHold: hasAction(this._config!.hold_action),

View File

@ -36,8 +36,6 @@
// Binding names // Binding names
"no-legacy-attribute": "error", "no-legacy-attribute": "error",
// Binding types // Binding types
"no-boolean-in-attribute-binding": "warning",
"no-nullable-attribute-binding": "warning",
"no-incompatible-type-binding": "warning", "no-incompatible-type-binding": "warning",
// LitElement // LitElement
"no-incompatible-property-type": "warning", "no-incompatible-property-type": "warning",