aboutsummaryrefslogtreecommitdiff
path: root/js/src/tooltip.js
diff options
context:
space:
mode:
authorXhmikosR <[email protected]>2021-09-09 15:01:58 +0300
committerGitHub <[email protected]>2021-09-09 15:01:58 +0300
commite961454738f4033eb2be68bde4b257ea9e0a7765 (patch)
tree507ca252e706a9c692b133b6e18fb8504c488837 /js/src/tooltip.js
parent86d5d5ea79e8eaa15a28b9da92bbee53036640f6 (diff)
parent1df098361cac04217d6a464c80e890c4335ecb5c (diff)
downloadbootstrap-main-xmr-docs-render-heading.tar.xz
bootstrap-main-xmr-docs-render-heading.zip
Merge branch 'main' into main-xmr-docs-render-headingmain-xmr-docs-render-heading
Diffstat (limited to 'js/src/tooltip.js')
-rw-r--r--js/src/tooltip.js27
1 files changed, 18 insertions, 9 deletions
diff --git a/js/src/tooltip.js b/js/src/tooltip.js
index 288146472..747555411 100644
--- a/js/src/tooltip.js
+++ b/js/src/tooltip.js
@@ -1,6 +1,6 @@
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.1.0): tooltip.js
+ * Bootstrap (v5.1.1): tooltip.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
@@ -211,10 +211,7 @@ class Tooltip extends BaseComponent {
this.tip.remove()
}
- if (this._popper) {
- this._popper.destroy()
- }
-
+ this._disposePopper()
super.dispose()
}
@@ -237,6 +234,14 @@ class Tooltip extends BaseComponent {
return
}
+ // A trick to recreate a tooltip in case a new title is given by using the NOT documented `data-bs-original-title`
+ // This will be removed later in favor of a `setContent` method
+ if (this.constructor.NAME === 'tooltip' && this.tip && this.getTitle() !== this.tip.querySelector(SELECTOR_TOOLTIP_INNER).innerHTML) {
+ this._disposePopper()
+ this.tip.remove()
+ this.tip = null
+ }
+
const tip = this.getTipElement()
const tipId = getUID(this.constructor.NAME)
@@ -319,10 +324,7 @@ class Tooltip extends BaseComponent {
this._element.removeAttribute('aria-describedby')
EventHandler.trigger(this._element, this.constructor.Event.HIDDEN)
- if (this._popper) {
- this._popper.destroy()
- this._popper = null
- }
+ this._disposePopper()
}
const hideEvent = EventHandler.trigger(this._element, this.constructor.Event.HIDE)
@@ -725,6 +727,13 @@ class Tooltip extends BaseComponent {
this._addAttachmentClass(this._getAttachment(state.placement))
}
+ _disposePopper() {
+ if (this._popper) {
+ this._popper.destroy()
+ this._popper = null
+ }
+ }
+
// Static
static jQueryInterface(config) {