aboutsummaryrefslogtreecommitdiff
path: root/js/src
diff options
context:
space:
mode:
Diffstat (limited to 'js/src')
-rw-r--r--js/src/popover.js4
-rw-r--r--js/src/tooltip.js9
2 files changed, 5 insertions, 8 deletions
diff --git a/js/src/popover.js b/js/src/popover.js
index 15deaafe2..dbd67558f 100644
--- a/js/src/popover.js
+++ b/js/src/popover.js
@@ -84,9 +84,7 @@ class Popover extends Tooltip {
return this.getTitle() || this._getContent()
}
- setContent() {
- const tip = this.getTipElement()
-
+ setContent(tip) {
this._sanitizeAndSetContent(tip, this.getTitle(), SELECTOR_TITLE)
this._sanitizeAndSetContent(tip, this._getContent(), SELECTOR_CONTENT)
}
diff --git a/js/src/tooltip.js b/js/src/tooltip.js
index f932a9ff9..2632e46e0 100644
--- a/js/src/tooltip.js
+++ b/js/src/tooltip.js
@@ -243,8 +243,6 @@ class Tooltip extends BaseComponent {
tip.setAttribute('id', tipId)
this._element.setAttribute('aria-describedby', tipId)
- this.setContent()
-
if (this._config.animation) {
tip.classList.add(CLASS_NAME_FADE)
}
@@ -371,20 +369,21 @@ class Tooltip extends BaseComponent {
element.innerHTML = this._config.template
const tip = element.children[0]
+ this.setContent(tip)
tip.classList.remove(CLASS_NAME_FADE, CLASS_NAME_SHOW)
this.tip = tip
return this.tip
}
- setContent() {
- const tip = this.getTipElement()
+ setContent(tip) {
this._sanitizeAndSetContent(tip, this.getTitle(), SELECTOR_TOOLTIP_INNER)
}
_sanitizeAndSetContent(template, content, selector) {
const templateElement = SelectorEngine.findOne(selector, template)
- if (!content) {
+
+ if (!content && templateElement) {
templateElement.remove()
return
}