From 9ac2eefe7f4a35ff64054b9c50c9d696065bf1f4 Mon Sep 17 00:00:00 2001 From: Jeri Peier Date: Thu, 23 Nov 2023 16:20:45 +0100 Subject: [PATCH] fix(sbb-toggle): supress warnings on SSR (#2228) --- src/components/toggle/toggle/toggle.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/toggle/toggle/toggle.ts b/src/components/toggle/toggle/toggle.ts index b024ab04e2..8d9b281c70 100644 --- a/src/components/toggle/toggle/toggle.ts +++ b/src/components/toggle/toggle/toggle.ts @@ -3,7 +3,7 @@ import { customElement, property } from 'lit/decorators.js'; import { ref } from 'lit/directives/ref.js'; import { isArrowKeyPressed, getNextElementIndex, interactivityChecker } from '../../core/a11y'; -import { toggleDatasetEntry, setAttribute } from '../../core/dom'; +import { toggleDatasetEntry, setAttribute, isBrowser } from '../../core/dom'; import { EventEmitter, ConnectedAbortController } from '../../core/eventing'; import { SbbCheckedStateChange, SbbStateChange, SbbValueStateChange } from '../../core/interfaces'; import { AgnosticResizeObserver } from '../../core/observers'; @@ -76,7 +76,7 @@ export class SbbToggle extends LitElement { const options = this._options; const selectedOption = options.find((o) => o.value === value) ?? options.find((o) => o.checked) ?? options[0]; - if (!selectedOption) { + if (!selectedOption && isBrowser()) { console.warn(`sbb-toggle: No available options! (${this.id || 'No id'})`); return; }