Use polyfill from toggleAttribute (#9969)

This commit is contained in:
Bram Kragten 2021-09-06 11:48:08 +02:00 committed by GitHub
parent c6e83cb7c0
commit 40664997e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 3 deletions

View File

@ -19,6 +19,7 @@ import { ifDefined } from "lit/directives/if-defined";
import { formatDateTimeWithSeconds } from "../../common/datetime/format_date_time"; import { formatDateTimeWithSeconds } from "../../common/datetime/format_date_time";
import relativeTime from "../../common/datetime/relative_time"; import relativeTime from "../../common/datetime/relative_time";
import { fireEvent } from "../../common/dom/fire_event"; import { fireEvent } from "../../common/dom/fire_event";
import { toggleAttribute } from "../../common/dom/toggle_attribute";
import { LogbookEntry } from "../../data/logbook"; import { LogbookEntry } from "../../data/logbook";
import { import {
ChooseAction, ChooseAction,
@ -552,7 +553,7 @@ export class HaAutomationTracer extends LitElement {
this.shadowRoot!.querySelectorAll<HaTimeline>( this.shadowRoot!.querySelectorAll<HaTimeline>(
"ha-timeline[data-path]" "ha-timeline[data-path]"
).forEach((el) => { ).forEach((el) => {
el.toggleAttribute("selected", this.selectedPath === el.dataset.path); toggleAttribute(el, "selected", this.selectedPath === el.dataset.path);
if (!this.allowPick || el.tabIndex === 0) { if (!this.allowPick || el.tabIndex === 0) {
return; return;
} }

View File

@ -61,7 +61,11 @@ class HuiGridCard extends HuiStackCard<GridCardConfig> {
setConfig(config: GridCardConfig) { setConfig(config: GridCardConfig) {
super.setConfig(config); super.setConfig(config);
this.style.setProperty("--grid-card-column-count", String(this.columns)); this.style.setProperty("--grid-card-column-count", String(this.columns));
this.toggleAttribute("square", this.square); if (this.square) {
this.setAttribute("square", "");
} else {
this.removeAttribute("square");
}
} }
static get styles(): CSSResultGroup { static get styles(): CSSResultGroup {

View File

@ -33,6 +33,7 @@ import "@material/mwc-icon-button/mwc-icon-button";
import "../../../components/ha-svg-icon"; import "../../../components/ha-svg-icon";
import "@material/mwc-button/mwc-button"; import "@material/mwc-button/mwc-button";
import "../../../components/ha-button-toggle-group"; import "../../../components/ha-button-toggle-group";
import { toggleAttribute } from "../../../common/dom/toggle_attribute";
const viewButtons: ToggleButton[] = [ const viewButtons: ToggleButton[] = [
{ label: "Day", value: "day" }, { label: "Day", value: "day" },
@ -55,7 +56,7 @@ export class HuiEnergyPeriodSelector extends SubscribeMixin(LitElement) {
public connectedCallback() { public connectedCallback() {
super.connectedCallback(); super.connectedCallback();
this.toggleAttribute("narrow", this.offsetWidth < 600); toggleAttribute(this, "narrow", this.offsetWidth < 600);
} }
public hassSubscribe(): UnsubscribeFunc[] { public hassSubscribe(): UnsubscribeFunc[] {