mirror of
https://github.com/twbs/bootstrap.git
synced 2024-12-01 13:24:25 +01:00
use one private method to resolve string or function
This commit is contained in:
parent
3716603dbc
commit
a97fd1cd24
@ -124,7 +124,7 @@ class Popover extends Tooltip {
|
|||||||
// Private
|
// Private
|
||||||
|
|
||||||
_getContent() {
|
_getContent() {
|
||||||
return this._element.getAttribute('data-bs-content') || this._config.content
|
return this._resolvePossibleFunction(this._config.content)
|
||||||
}
|
}
|
||||||
|
|
||||||
_getBasicClassPrefix() {
|
_getBasicClassPrefix() {
|
||||||
|
@ -17,10 +17,7 @@ import {
|
|||||||
noop,
|
noop,
|
||||||
typeCheckConfig
|
typeCheckConfig
|
||||||
} from './util/index'
|
} from './util/index'
|
||||||
import {
|
import { DefaultAllowlist, sanitizeHtml } from './util/sanitizer'
|
||||||
DefaultAllowlist,
|
|
||||||
sanitizeHtml
|
|
||||||
} from './util/sanitizer'
|
|
||||||
import Data from './dom/data'
|
import Data from './dom/data'
|
||||||
import EventHandler from './dom/event-handler'
|
import EventHandler from './dom/event-handler'
|
||||||
import Manipulator from './dom/manipulator'
|
import Manipulator from './dom/manipulator'
|
||||||
@ -272,7 +269,7 @@ class Tooltip extends BaseComponent {
|
|||||||
|
|
||||||
tip.classList.add(CLASS_NAME_SHOW)
|
tip.classList.add(CLASS_NAME_SHOW)
|
||||||
|
|
||||||
const customClass = typeof this._config.customClass === 'function' ? this._config.customClass() : this._config.customClass
|
const customClass = this._resolvePossibleFunction(this._config.customClass)
|
||||||
if (customClass) {
|
if (customClass) {
|
||||||
tip.classList.add(...customClass.split(' '))
|
tip.classList.add(...customClass.split(' '))
|
||||||
}
|
}
|
||||||
@ -413,15 +410,9 @@ class Tooltip extends BaseComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getTitle() {
|
getTitle() {
|
||||||
let title = this._element.getAttribute('data-bs-original-title')
|
const title = this._element.getAttribute('data-bs-original-title') || this._config.title
|
||||||
|
|
||||||
if (!title) {
|
return this._resolvePossibleFunction(title)
|
||||||
title = typeof this._config.title === 'function' ?
|
|
||||||
this._config.title.call(this._element) :
|
|
||||||
this._config.title
|
|
||||||
}
|
|
||||||
|
|
||||||
return title
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateAttachment(attachment) {
|
updateAttachment(attachment) {
|
||||||
@ -456,6 +447,10 @@ class Tooltip extends BaseComponent {
|
|||||||
return offset
|
return offset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_resolvePossibleFunction(content) {
|
||||||
|
return typeof content === 'function' ? content.call(this._element) : content
|
||||||
|
}
|
||||||
|
|
||||||
_getPopperConfig(attachment) {
|
_getPopperConfig(attachment) {
|
||||||
const defaultBsPopperConfig = {
|
const defaultBsPopperConfig = {
|
||||||
placement: attachment,
|
placement: attachment,
|
||||||
|
Loading…
Reference in New Issue
Block a user