From: GeoSot Date: Thu, 25 Nov 2021 18:33:42 +0000 (+0200) Subject: Tooltip: refactor jQueryInterface X-Git-Tag: v5.2.0-beta1~389 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=53c77c020368dbd570bd2d29ffc0c3660a0f6ab3;p=thirdparty%2Fbootstrap.git Tooltip: refactor jQueryInterface --- diff --git a/js/src/popover.js b/js/src/popover.js index 19c1e42a4d..aea1b97020 100644 --- a/js/src/popover.js +++ b/js/src/popover.js @@ -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]() }) } } diff --git a/js/src/tooltip.js b/js/src/tooltip.js index b09ab0d0ca..b0963a0021 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -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]() }) } }