Skip to content

Commit 9f564a9

Browse files
damcousgeleonandreishichko
authored
Bugfix/mage 948/dom selector 3.14 (#1552)
* MAGE-3 Checking on exists element fix (#1516) Co-authored-by: andreishichko <[email protected]> * MAGE-948: use if statement over ternary * MAGE-948: remove optional chaining --------- Co-authored-by: sgeleon <[email protected]> Co-authored-by: andreishichko <[email protected]>
1 parent 42280ae commit 9f564a9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

view/frontend/web/internals/common.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ define(['jquery', 'algoliaBundle'], function ($, algoliaBundle) {
1414
return acc;
1515
}, {});
1616

17-
window.algolia = {
17+
window.algolia = {
1818
deprecatedHooks: [
1919
'beforeAutocompleteProductSourceOptions',
2020
'beforeAutocompleteSources'
@@ -85,7 +85,7 @@ define(['jquery', 'algoliaBundle'], function ($, algoliaBundle) {
8585
htmlspecialcharsEncode: string => {
8686
const regex = new RegExp(`[${Object.keys(SPECIAL_CHAR_ENCODE_MAP).join('')}]`, 'g');
8787
return string.replace(regex, (m) => SPECIAL_CHAR_ENCODE_MAP[m]);
88-
}
88+
}
8989
};
9090

9191
window.isMobile = function () {
@@ -629,7 +629,9 @@ define(['jquery', 'algoliaBundle'], function ($, algoliaBundle) {
629629
var input = $(this).closest('#algolia-searchbox').find('input');
630630

631631
input.val('');
632-
input.get(0).dispatchEvent(new Event('input'));
632+
if (input.length) {
633+
input.get(0).dispatchEvent(new Event('input'));
634+
}
633635

634636
handleInputCrossAutocomplete(input);
635637
});

0 commit comments

Comments
 (0)