1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-10 15:44:51 +02:00

Popover - call content once if it's a function. (#24690)

This commit is contained in:
Johann-S
2017-11-07 08:18:52 +01:00
committed by XhmikosR
parent b42a38b886
commit 26dc17bcd2
2 changed files with 27 additions and 4 deletions

View File

@@ -124,7 +124,11 @@ const Popover = (($) => {
// we use append for html objects to maintain js events
this.setElementContent($tip.find(Selector.TITLE), this.getTitle())
this.setElementContent($tip.find(Selector.CONTENT), this._getContent())
let content = this._getContent()
if (typeof content === 'function') {
content = content.call(this.element)
}
this.setElementContent($tip.find(Selector.CONTENT), content)
$tip.removeClass(`${ClassName.FADE} ${ClassName.SHOW}`)
}
@@ -133,9 +137,7 @@ const Popover = (($) => {
_getContent() {
return this.element.getAttribute('data-content')
|| (typeof this.config.content === 'function' ?
this.config.content.call(this.element) :
this.config.content)
|| this.config.content
}
_cleanTipClass() {