MDL-70075 core: Do not return a value in an event handler
authorAndrew Nicols <andrew@nicols.co.uk>
Mon, 2 Nov 2020 07:42:38 +0000 (15:42 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Thu, 5 Nov 2020 01:05:38 +0000 (09:05 +0800)
Returning a value of `false` in an event handler has the effect of
calling event.preventDefault() and event.stopPropagation().

This is neither obvious, nor desirable in this situation.

lib/amd/build/form-autocomplete.min.js
lib/amd/build/form-autocomplete.min.js.map
lib/amd/src/form-autocomplete.js

index fa95f55..c9f2aca 100644 (file)
Binary files a/lib/amd/build/form-autocomplete.min.js and b/lib/amd/build/form-autocomplete.min.js differ
index db17485..d4a4e03 100644 (file)
Binary files a/lib/amd/build/form-autocomplete.min.js.map and b/lib/amd/build/form-autocomplete.min.js.map differ
index 72a6e57..8c357fb 100644 (file)
@@ -821,7 +821,8 @@ function($, log, str, templates, notification, LoadingIcon, Aria) {
             // Find the active one.
             var element = selectionsElement.children('[data-active-selection]');
             if (!element.length) {
-                return activateSelection(0, state);
+                activateSelection(0, state);
+                return;
             }
         });
         // Keyboard navigation for the selection list.
@@ -835,7 +836,7 @@ function($, log, str, templates, notification, LoadingIcon, Aria) {
 
                     // Choose the next selection item.
                     pendingPromise.resolve(activateNextSelection(state));
-                    return false;
+                    return;
                 case KEYS.LEFT:
                 case KEYS.UP:
                     // We handled this event, so prevent it.
@@ -843,7 +844,7 @@ function($, log, str, templates, notification, LoadingIcon, Aria) {
 
                     // Choose the previous selection item.
                     pendingPromise.resolve(activatePreviousSelection(state));
-                    return false;
+                    return;
                 case KEYS.SPACE:
                 case KEYS.ENTER:
                     // Get the item that is currently selected.
@@ -854,12 +855,11 @@ function($, log, str, templates, notification, LoadingIcon, Aria) {
                         // Unselect this item.
                         pendingPromise.resolve(deselectItem(options, state, selectedItem, originalSelect));
                     }
-                    return false;
+                    return;
             }
 
             // Not handled. Resolve the promise.
             pendingPromise.resolve();
-            return true;
         });
         // Whenever the input field changes, update the suggestion list.
         if (options.showSuggestions) {