mirror of
https://github.com/twbs/bootstrap.git
synced 2025-02-07 04:54:24 +01:00
fix tooltip/popper disposal inconsistencies (#37235)
This commit is contained in:
parent
bf6240dad9
commit
01dc2f5100
@ -172,10 +172,6 @@ class Tooltip extends BaseComponent {
|
|||||||
|
|
||||||
EventHandler.off(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler)
|
EventHandler.off(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler)
|
||||||
|
|
||||||
if (this.tip) {
|
|
||||||
this.tip.remove()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this._element.getAttribute('data-bs-original-title')) {
|
if (this._element.getAttribute('data-bs-original-title')) {
|
||||||
this._element.setAttribute('title', this._element.getAttribute('data-bs-original-title'))
|
this._element.setAttribute('title', this._element.getAttribute('data-bs-original-title'))
|
||||||
}
|
}
|
||||||
@ -202,10 +198,7 @@ class Tooltip extends BaseComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// todo v6 remove this OR make it optional
|
// todo v6 remove this OR make it optional
|
||||||
if (this.tip) {
|
this._disposePopper()
|
||||||
this.tip.remove()
|
|
||||||
this.tip = null
|
|
||||||
}
|
|
||||||
|
|
||||||
const tip = this._getTipElement()
|
const tip = this._getTipElement()
|
||||||
|
|
||||||
@ -218,11 +211,7 @@ class Tooltip extends BaseComponent {
|
|||||||
EventHandler.trigger(this._element, this.constructor.eventName(EVENT_INSERTED))
|
EventHandler.trigger(this._element, this.constructor.eventName(EVENT_INSERTED))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._popper) {
|
|
||||||
this._popper.update()
|
|
||||||
} else {
|
|
||||||
this._popper = this._createPopper(tip)
|
this._popper = this._createPopper(tip)
|
||||||
}
|
|
||||||
|
|
||||||
tip.classList.add(CLASS_NAME_SHOW)
|
tip.classList.add(CLASS_NAME_SHOW)
|
||||||
|
|
||||||
@ -281,13 +270,11 @@ class Tooltip extends BaseComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!this._isHovered) {
|
if (!this._isHovered) {
|
||||||
tip.remove()
|
this._disposePopper()
|
||||||
}
|
}
|
||||||
|
|
||||||
this._element.removeAttribute('aria-describedby')
|
this._element.removeAttribute('aria-describedby')
|
||||||
EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDDEN))
|
EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDDEN))
|
||||||
|
|
||||||
this._disposePopper()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this._queueCallback(complete, this.tip, this._isAnimated())
|
this._queueCallback(complete, this.tip, this._isAnimated())
|
||||||
@ -612,6 +599,11 @@ class Tooltip extends BaseComponent {
|
|||||||
this._popper.destroy()
|
this._popper.destroy()
|
||||||
this._popper = null
|
this._popper = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.tip) {
|
||||||
|
this.tip.remove()
|
||||||
|
this.tip = null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
|
Loading…
x
Reference in New Issue
Block a user