Skip to content

Commit 173fbc0

Browse files
committed
MAGE-899 Clean up buildAutocompleteSource
1 parent e1c2e75 commit 173fbc0

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

view/frontend/web/js/autocomplete.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -246,15 +246,16 @@ define([
246246
buildAutocompleteSource(section, searchClient) {
247247
const defaultSourceConfig = this.buildAutocompleteSourceDefault(section);
248248

249-
if (section.name === 'products') {
250-
return this.buildAutocompleteSourceProducts(section, defaultSourceConfig);
251-
} else if (section.name === 'categories') {
252-
return this.buildAutocompleteSourceCategories(section, defaultSourceConfig);
253-
} else if (section.name === 'pages') {
254-
return this.buildAutocompleteSourcePages(section, defaultSourceConfig);
255-
} else {
256-
/** If is not products, categories, pages or suggestions, it's additional section **/
257-
return this.buildAutocompleteSourceAdditional(section, defaultSourceConfig);
249+
switch (section.name) {
250+
case 'products':
251+
return this.buildAutocompleteSourceProducts(section, defaultSourceConfig);
252+
case 'categories':
253+
return this.buildAutocompleteSourceCategories(section, defaultSourceConfig);
254+
case 'pages':
255+
return this.buildAutocompleteSourcePages(section, defaultSourceConfig);
256+
default:
257+
/** If is not products, categories, or pages, it's an additional section **/
258+
return this.buildAutocompleteSourceAdditional(section, defaultSourceConfig);
258259
}
259260
},
260261

0 commit comments

Comments
 (0)