From 51afe026ca1c08d228cb58cbe47f8c3d61167c96 Mon Sep 17 00:00:00 2001 From: GeoSot Date: Tue, 31 Aug 2021 16:11:22 +0300 Subject: Fix tooltip `data-bs-original-title` issue (#34842) --- js/src/tooltip.js | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 288146472..f65fd517a 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -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) { -- cgit v1.2.3 From 0d81d3cbc14dfcdca8a868e3f25189a4f1ab273c Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Tue, 7 Sep 2021 18:37:44 +0300 Subject: Release v5.1.1 (#34869) * Prepare v5.1.1. * Dist --- js/src/tooltip.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index f65fd517a..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) * -------------------------------------------------------------------------- */ -- cgit v1.2.3