Skip to content

Commit 42155a0

Browse files
committed
Fix tests
1 parent 2fe9d04 commit 42155a0

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/lib/DocsSearchBar.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,10 @@ class DocsSearchBar {
8989
this.autocompleteOptions.cssClasses.prefix || 'dsb';
9090
this.autocompleteOptions.cssClasses.root =
9191
this.autocompleteOptions.cssClasses.root || 'meilisearch-autocomplete';
92-
this.autocompleteOptions.keyboardShortcuts = this.parseHotkeysAutocompleteOptions(
93-
this.autocompleteOptions.keyboardShortcuts
94-
) || ['s', 191];
92+
this.autocompleteOptions.keyboardShortcuts =
93+
this.parseHotkeysAutocompleteOptions(
94+
this.autocompleteOptions.keyboardShortcuts
95+
) || ['s', 191];
9596

9697
this.isSimpleLayout = layout === 'simple';
9798
this.enableDarkMode = enableDarkMode;
@@ -100,10 +101,12 @@ class DocsSearchBar {
100101
window.matchMedia &&
101102
window.matchMedia('(prefers-color-scheme: dark)').matches;
102103
const searchbox = document.querySelector('.docs-searchbar');
103-
if (this.enableDarkMode && isSystemInDarkMode) {
104-
searchbox.setAttribute('data-ds-theme', 'dark')
105-
} else {
106-
searchbox.setAttribute('data-ds-theme', 'ligh')
104+
if (searchbox) {
105+
if (this.enableDarkMode && isSystemInDarkMode) {
106+
searchbox.setAttribute('data-ds-theme', 'dark');
107+
} else {
108+
searchbox.setAttribute('data-ds-theme', 'ligh');
109+
}
107110
}
108111

109112
this.client = new MeiliSearch({
@@ -182,7 +185,7 @@ class DocsSearchBar {
182185
throw new Error(
183186
`Error: "enableDarkMode" must be of type: boolean. Found type: ${typeof args.inputSelector}`
184187
);
185-
}
188+
}
186189
}
187190

188191
static injectSearchBox(input) {

0 commit comments

Comments
 (0)