1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-06 13:46:42 +02:00

Regression on tooltip template creation process. (#34628)

* Regression on tooltip template creation process.

* check if template content does not exist, or given argument is empty

* call `setContent()` once.
This commit is contained in:
GeoSot
2021-08-03 11:59:33 +03:00
committed by GitHub
parent 23fd488c38
commit a6a2d1e2df
4 changed files with 39 additions and 11 deletions

View File

@@ -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)
}

View File

@@ -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
}