0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-01-18 10:52:19 +01:00

Tooltip: refactor jQueryInterface

This commit is contained in:
GeoSot 2021-11-25 20:33:42 +02:00 committed by XhmikosR
parent a5945369bd
commit 53c77c0203
2 changed files with 16 additions and 12 deletions

View 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}"`)
}
data[config]()
if (typeof config !== 'string') {
return
}
if (typeof data[config] === 'undefined') {
throw new TypeError(`No method named "${config}"`)
}
data[config]()
})
}
}

View 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}"`)
}
data[config]()
if (typeof config !== 'string') {
return
}
if (typeof data[config] === 'undefined') {
throw new TypeError(`No method named "${config}"`)
}
data[config]()
})
}
}