]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Tooltip: refactor jQueryInterface
authorGeoSot <geo.sotis@gmail.com>
Thu, 25 Nov 2021 18:33:42 +0000 (20:33 +0200)
committerXhmikosR <xhmikosr@gmail.com>
Wed, 1 Dec 2021 16:00:36 +0000 (18:00 +0200)
js/src/popover.js
js/src/tooltip.js

index 19c1e42a4d4bbbdca0bf1408d5f209678c5ec82d..aea1b97020e65d9cf10c15bdd8dc4537f2178705 100644 (file)
@@ -94,13 +94,15 @@ class Popover extends Tooltip {
     return this.each(function () {
       const data = Popover.getOrCreateInstance(this, config)
 
-      if (typeof config === 'string') {
-        if (typeof data[config] === 'undefined') {
-          throw new TypeError(`No method named "${config}"`)
-        }
+      if (typeof config !== 'string') {
+        return
+      }
 
-        data[config]()
+      if (typeof data[config] === 'undefined') {
+        throw new TypeError(`No method named "${config}"`)
       }
+
+      data[config]()
     })
   }
 }
index b09ab0d0cae495459c0e13a4b64357ac9a78d184..b0963a00213a10f703025a66e1b673f7ae004a54 100644 (file)
@@ -637,13 +637,15 @@ class Tooltip extends BaseComponent {
     return this.each(function () {
       const data = Tooltip.getOrCreateInstance(this, config)
 
-      if (typeof config === 'string') {
-        if (typeof data[config] === 'undefined') {
-          throw new TypeError(`No method named "${config}"`)
-        }
+      if (typeof config !== 'string') {
+        return
+      }
 
-        data[config]()
+      if (typeof data[config] === 'undefined') {
+        throw new TypeError(`No method named "${config}"`)
       }
+
+      data[config]()
     })
   }
 }