]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Return early in more places
authorXhmikosR <xhmikosr@gmail.com>
Tue, 9 Nov 2021 13:44:14 +0000 (15:44 +0200)
committerXhmikosR <xhmikosr@gmail.com>
Sat, 29 Jan 2022 11:25:30 +0000 (13:25 +0200)
js/src/carousel.js
js/src/dom/event-handler.js

index fe3ccf94e80e2fc279763d07d1f837f3adb26698..5a0cbc208de744c19d963480ba4641921bbc6e85 100644 (file)
@@ -225,22 +225,24 @@ class Carousel extends BaseComponent {
     }
 
     const endCallBack = () => {
-      if (this._config.pause === 'hover') {
-        // If it's a touch-enabled device, mouseenter/leave are fired as
-        // part of the mouse compatibility events on first tap - the carousel
-        // would stop cycling until user tapped out of it;
-        // here, we listen for touchend, explicitly pause the carousel
-        // (as if it's the second time we tap on it, mouseenter compat event
-        // is NOT fired) and after a timeout (to allow for mouse compatibility
-        // events to fire) we explicitly restart cycling
-
-        this.pause()
-        if (this.touchTimeout) {
-          clearTimeout(this.touchTimeout)
-        }
-
-        this.touchTimeout = setTimeout(event => this.cycle(event), TOUCHEVENT_COMPAT_WAIT + this._config.interval)
+      if (this._config.pause !== 'hover') {
+        return
       }
+
+      // If it's a touch-enabled device, mouseenter/leave are fired as
+      // part of the mouse compatibility events on first tap - the carousel
+      // would stop cycling until user tapped out of it;
+      // here, we listen for touchend, explicitly pause the carousel
+      // (as if it's the second time we tap on it, mouseenter compat event
+      // is NOT fired) and after a timeout (to allow for mouse compatibility
+      // events to fire) we explicitly restart cycling
+
+      this.pause()
+      if (this.touchTimeout) {
+        clearTimeout(this.touchTimeout)
+      }
+
+      this.touchTimeout = setTimeout(event => this.cycle(event), TOUCHEVENT_COMPAT_WAIT + this._config.interval)
     }
 
     const swipeConfig = {
index 7c54a97657b85a7241397f86097d3c6f017db4ea..12b157467c4f29834b824101181cc66652573c98 100644 (file)
@@ -105,15 +105,17 @@ function bootstrapDelegationHandler(element, selector, fn) {
 
     for (let { target } = event; target && target !== this; target = target.parentNode) {
       for (const domElement of domElements) {
-        if (domElement === target) {
-          event.delegateTarget = target
+        if (domElement !== target) {
+          continue
+        }
 
-          if (handler.oneOff) {
-            EventHandler.off(element, event.type, selector, fn)
-          }
+        event.delegateTarget = target
 
-          return fn.apply(target, [event])
+        if (handler.oneOff) {
+          EventHandler.off(element, event.type, selector, fn)
         }
+
+        return fn.apply(target, [event])
       }
     }