Skip to content

Commit

Permalink
fix(sbb-toggle): supress warnings on SSR (#2228)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeripeierSBB authored Nov 23, 2023
1 parent b00e2d3 commit 9ac2eef
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/toggle/toggle/toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 9ac2eef

Please sign in to comment.