From 26dc17bcd23fd2f5fd762c5cb73c6a670bd5f897 Mon Sep 17 00:00:00 2001 From: Johann-S Date: Tue, 7 Nov 2017 08:18:52 +0100 Subject: Popover - call `content` once if it's a function. (#24690) --- js/src/popover.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'js/src') diff --git a/js/src/popover.js b/js/src/popover.js index 4fb96a792..5534f4441 100644 --- a/js/src/popover.js +++ b/js/src/popover.js @@ -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() { -- cgit v1.2.3