From 44a6cd724c0a5c5247492fdb8db7d4df4705641e Mon Sep 17 00:00:00 2001 From: GeoSot Date: Wed, 1 Dec 2021 14:53:56 +0200 Subject: Tooltip: remove leftover method (#35440) Remove a leftover after #32692 Co-authored-by: XhmikosR --- js/src/tooltip.js | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 29be4d8d2..d0b43dd04 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -398,18 +398,6 @@ class Tooltip extends BaseComponent { return this._resolvePossibleFunction(this._config.title) || this._element.getAttribute('title') } - updateAttachment(attachment) { - if (attachment === 'right') { - return 'end' - } - - if (attachment === 'left') { - return 'start' - } - - return attachment - } - // Private _initializeOnDelegatedTarget(event, context) { return context || this.constructor.getOrCreateInstance(event.delegateTarget, this._getDelegateConfig()) -- cgit v1.2.3 From cab62af2e6ecddbadbf799e00f911c2b342d93b2 Mon Sep 17 00:00:00 2001 From: GeoSot Date: Wed, 1 Dec 2021 15:10:10 +0200 Subject: Fix popover arrow & tooltip template after the `setContent` addition (#35441) --- js/src/tooltip.js | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index d0b43dd04..b09ab0d0c 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -38,7 +38,6 @@ const CLASS_NAME_SHOW = 'show' const HOVER_STATE_SHOW = 'show' const HOVER_STATE_OUT = 'out' -const SELECTOR_TOOLTIP_ARROW = '.tooltip-arrow' const SELECTOR_TOOLTIP_INNER = '.tooltip-inner' const SELECTOR_MODAL = `.${CLASS_NAME_MODAL}` @@ -333,15 +332,23 @@ class Tooltip extends BaseComponent { } getTipElement() { - if (this.tip) { - return this.tip + if (!this.tip) { + this.tip = this._createTipElement(this._getContentForTemplate()) } - const templateFactory = this._getTemplateFactory(this._getContentForTemplate()) + return this.tip + } + + _createTipElement(content) { + const tip = this._getTemplateFactory(content).toHtml() + + // todo: remove this check on v6 + if (!tip) { + return null + } - const tip = templateFactory.toHtml() tip.classList.remove(CLASS_NAME_FADE, CLASS_NAME_SHOW) - // todo on v6 the following can be done on css only + // todo: on v6 the following can be achieved with CSS only tip.classList.add(`bs-${this.constructor.NAME}-auto`) const tipId = getUID(this.constructor.NAME).toString() @@ -352,8 +359,7 @@ class Tooltip extends BaseComponent { tip.classList.add(CLASS_NAME_FADE) } - this.tip = tip - return this.tip + return tip } setContent(content) { @@ -361,11 +367,11 @@ class Tooltip extends BaseComponent { if (this.tip) { isShown = this.tip.classList.contains(CLASS_NAME_SHOW) this.tip.remove() + this.tip = null } this._disposePopper() - - this.tip = this._getTemplateFactory(content).toHtml() + this.tip = this._createTipElement(content) if (isShown) { this.show() @@ -446,7 +452,7 @@ class Tooltip extends BaseComponent { { name: 'arrow', options: { - element: SELECTOR_TOOLTIP_ARROW + element: `.${this.constructor.NAME}-arrow` } } ] -- cgit v1.2.3 From 53c77c020368dbd570bd2d29ffc0c3660a0f6ab3 Mon Sep 17 00:00:00 2001 From: GeoSot Date: Thu, 25 Nov 2021 20:33:42 +0200 Subject: Tooltip: refactor jQueryInterface --- js/src/tooltip.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index b09ab0d0c..b0963a002 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -637,13 +637,15 @@ class Tooltip extends BaseComponent { return this.each(function () { const data = Tooltip.getOrCreateInstance(this, config) - if (typeof config === 'string') { - if (typeof data[config] === 'undefined') { - throw new TypeError(`No method named "${config}"`) - } + if (typeof config !== 'string') { + return + } - data[config]() + if (typeof data[config] === 'undefined') { + throw new TypeError(`No method named "${config}"`) } + + data[config]() }) } } -- cgit v1.2.3 From 3baeb0a5c12eb1bcea9336c883e8788b9dad68f8 Mon Sep 17 00:00:00 2001 From: GeoSot Date: Fri, 26 Nov 2021 02:15:24 +0200 Subject: Tooltip: merge `isAnimated` checks --- js/src/tooltip.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index b0963a002..a1e701981 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -271,8 +271,7 @@ class Tooltip extends BaseComponent { } } - const isAnimated = this.tip.classList.contains(CLASS_NAME_FADE) - this._queueCallback(complete, this.tip, isAnimated) + this._queueCallback(complete, this.tip, this._isAnimated()) } hide() { @@ -315,8 +314,7 @@ class Tooltip extends BaseComponent { this._activeTrigger[TRIGGER_FOCUS] = false this._activeTrigger[TRIGGER_HOVER] = false - const isAnimated = this.tip.classList.contains(CLASS_NAME_FADE) - this._queueCallback(complete, this.tip, isAnimated) + this._queueCallback(complete, this.tip, this._isAnimated()) this._hoverState = '' } @@ -355,7 +353,7 @@ class Tooltip extends BaseComponent { tip.setAttribute('id', tipId) - if (this._config.animation) { + if (this._isAnimated()) { tip.classList.add(CLASS_NAME_FADE) } @@ -409,6 +407,10 @@ class Tooltip extends BaseComponent { return context || this.constructor.getOrCreateInstance(event.delegateTarget, this._getDelegateConfig()) } + _isAnimated() { + return this._config.animation || (this.tip && this.tip.classList.contains(CLASS_NAME_FADE)) + } + _getOffset() { const { offset } = this._config -- cgit v1.2.3 From 724663b3cdebf436649d250c5ab52cca8f0c9320 Mon Sep 17 00:00:00 2001 From: GeoSot Date: Sun, 28 Nov 2021 02:46:28 +0200 Subject: Tooltip: Remove `Data.set` usage for dynamically created tip This is not used any further, so we were just setting it. --- js/src/tooltip.js | 2 -- 1 file changed, 2 deletions(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index a1e701981..3027b8f4c 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -16,7 +16,6 @@ import { typeCheckConfig } from './util/index' import { DefaultAllowlist } from './util/sanitizer' -import Data from './dom/data' import EventHandler from './dom/event-handler' import Manipulator from './dom/manipulator' import BaseComponent from './base-component' @@ -231,7 +230,6 @@ class Tooltip extends BaseComponent { this._element.setAttribute('aria-describedby', tip.getAttribute('id')) const { container } = this._config - Data.set(tip, this.constructor.DATA_KEY, this) if (!this._element.ownerDocument.documentElement.contains(this.tip)) { container.append(tip) -- cgit v1.2.3 From a20e4203fe951593e804254f8d0593a822dc5e50 Mon Sep 17 00:00:00 2001 From: GeoSot Date: Sun, 28 Nov 2021 03:06:15 +0200 Subject: Tooltip: Remove redundant `config.delay` check `config.delay` is always an object after initialization --- js/src/tooltip.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 3027b8f4c..ccec08dda 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -528,7 +528,7 @@ class Tooltip extends BaseComponent { context._hoverState = HOVER_STATE_SHOW - if (!context._config.delay || !context._config.delay.show) { + if (!context._config.delay.show) { context.show() return } @@ -557,7 +557,7 @@ class Tooltip extends BaseComponent { context._hoverState = HOVER_STATE_OUT - if (!context._config.delay || !context._config.delay.hide) { + if (!context._config.delay.hide) { context.hide() return } -- cgit v1.2.3 From c69ccba08cd4f16d42bd83ffd40d2a57c9ca0ffc Mon Sep 17 00:00:00 2001 From: GeoSot Date: Sun, 28 Nov 2021 03:09:42 +0200 Subject: Tooltip: Change `_enter` & `_leave` to work without arguments --- js/src/tooltip.js | 86 ++++++++++++++++++++++++++----------------------------- 1 file changed, 40 insertions(+), 46 deletions(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index ccec08dda..645a6b7e2 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -179,17 +179,17 @@ class Tooltip extends BaseComponent { context._activeTrigger.click = !context._activeTrigger.click if (context._isWithActiveTrigger()) { - context._enter(null, context) + context._enter() } else { - context._leave(null, context) + context._leave() } } else { if (this.getTipElement().classList.contains(CLASS_NAME_SHOW)) { - this._leave(null, this) + this._leave() return } - this._enter(null, this) + this._enter() } } @@ -265,7 +265,7 @@ class Tooltip extends BaseComponent { EventHandler.trigger(this._element, this.constructor.Event.SHOWN) if (prevHoverState === HOVER_STATE_OUT) { - this._leave(null, this) + this._leave() } } @@ -401,8 +401,8 @@ class Tooltip extends BaseComponent { } // Private - _initializeOnDelegatedTarget(event, context) { - return context || this.constructor.getOrCreateInstance(event.delegateTarget, this._getDelegateConfig()) + _initializeOnDelegatedTarget(event) { + return this.constructor.getOrCreateInstance(event.delegateTarget, this._getDelegateConfig()) } _isAnimated() { @@ -478,8 +478,18 @@ class Tooltip extends BaseComponent { this.constructor.Event.MOUSELEAVE : this.constructor.Event.FOCUSOUT - EventHandler.on(this._element, eventIn, this._config.selector, event => this._enter(event)) - EventHandler.on(this._element, eventOut, this._config.selector, event => this._leave(event)) + EventHandler.on(this._element, eventIn, this._config.selector, event => { + const context = this._initializeOnDelegatedTarget(event) + context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true + context._enter() + }) + EventHandler.on(this._element, eventOut, this._config.selector, event => { + const context = this._initializeOnDelegatedTarget(event) + context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = + context._element.contains(event.relatedTarget) + + context._leave() + }) } } @@ -510,63 +520,47 @@ class Tooltip extends BaseComponent { } } - _enter(event, context) { - context = this._initializeOnDelegatedTarget(event, context) - - if (event) { - context._activeTrigger[ - event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER - ] = true - } - - if (context.getTipElement().classList.contains(CLASS_NAME_SHOW) || context._hoverState === HOVER_STATE_SHOW) { - context._hoverState = HOVER_STATE_SHOW + _enter() { + if (this.getTipElement().classList.contains(CLASS_NAME_SHOW) || this._hoverState === HOVER_STATE_SHOW) { + this._hoverState = HOVER_STATE_SHOW return } - clearTimeout(context._timeout) + clearTimeout(this._timeout) - context._hoverState = HOVER_STATE_SHOW + this._hoverState = HOVER_STATE_SHOW - if (!context._config.delay.show) { - context.show() + if (!this._config.delay.show) { + this.show() return } - context._timeout = setTimeout(() => { - if (context._hoverState === HOVER_STATE_SHOW) { - context.show() + this._timeout = setTimeout(() => { + if (this._hoverState === HOVER_STATE_SHOW) { + this.show() } - }, context._config.delay.show) + }, this._config.delay.show) } - _leave(event, context) { - context = this._initializeOnDelegatedTarget(event, context) - - if (event) { - context._activeTrigger[ - event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER - ] = context._element.contains(event.relatedTarget) - } - - if (context._isWithActiveTrigger()) { + _leave() { + if (this._isWithActiveTrigger()) { return } - clearTimeout(context._timeout) + clearTimeout(this._timeout) - context._hoverState = HOVER_STATE_OUT + this._hoverState = HOVER_STATE_OUT - if (!context._config.delay.hide) { - context.hide() + if (!this._config.delay.hide) { + this.hide() return } - context._timeout = setTimeout(() => { - if (context._hoverState === HOVER_STATE_OUT) { - context.hide() + this._timeout = setTimeout(() => { + if (this._hoverState === HOVER_STATE_OUT) { + this.hide() } - }, context._config.delay.hide) + }, this._config.delay.hide) } _isWithActiveTrigger() { -- cgit v1.2.3 From 8eacbaa08b1b8a5a935fd31368388f3f7e9e25da Mon Sep 17 00:00:00 2001 From: GeoSot Date: Sun, 28 Nov 2021 03:58:59 +0200 Subject: Tooltip: merge timeout functionality --- js/src/tooltip.js | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 645a6b7e2..35abd2944 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -526,16 +526,9 @@ class Tooltip extends BaseComponent { return } - clearTimeout(this._timeout) - this._hoverState = HOVER_STATE_SHOW - if (!this._config.delay.show) { - this.show() - return - } - - this._timeout = setTimeout(() => { + this._setTimeout(() => { if (this._hoverState === HOVER_STATE_SHOW) { this.show() } @@ -547,22 +540,20 @@ class Tooltip extends BaseComponent { return } - clearTimeout(this._timeout) - this._hoverState = HOVER_STATE_OUT - if (!this._config.delay.hide) { - this.hide() - return - } - - this._timeout = setTimeout(() => { + this._setTimeout(() => { if (this._hoverState === HOVER_STATE_OUT) { this.hide() } }, this._config.delay.hide) } + _setTimeout(handler, timeout) { + clearTimeout(this._timeout) + this._timeout = setTimeout(handler, timeout) + } + _isWithActiveTrigger() { return Object.values(this._activeTrigger).includes(true) } -- cgit v1.2.3 From 9b9372e8ddd60413f3d9a582bd5481586d119d8d Mon Sep 17 00:00:00 2001 From: GeoSot Date: Sun, 28 Nov 2021 04:02:10 +0200 Subject: Tooltip: refactor `_hoverState` to Boolean to achieve better control --- js/src/tooltip.js | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 35abd2944..f03f9ef4d 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -34,9 +34,6 @@ const CLASS_NAME_FADE = 'fade' const CLASS_NAME_MODAL = 'modal' const CLASS_NAME_SHOW = 'show' -const HOVER_STATE_SHOW = 'show' -const HOVER_STATE_OUT = 'out' - const SELECTOR_TOOLTIP_INNER = '.tooltip-inner' const SELECTOR_MODAL = `.${CLASS_NAME_MODAL}` @@ -126,7 +123,7 @@ class Tooltip extends BaseComponent { // Private this._isEnabled = true this._timeout = 0 - this._hoverState = '' + this._isHovered = false this._activeTrigger = {} this._popper = null this._templateFactory = null @@ -259,12 +256,12 @@ class Tooltip extends BaseComponent { } const complete = () => { - const prevHoverState = this._hoverState + const prevHoverState = this._isHovered - this._hoverState = null + this._isHovered = false EventHandler.trigger(this._element, this.constructor.Event.SHOWN) - if (prevHoverState === HOVER_STATE_OUT) { + if (prevHoverState) { this._leave() } } @@ -283,7 +280,7 @@ class Tooltip extends BaseComponent { return } - if (this._hoverState !== HOVER_STATE_SHOW) { + if (!this._isHovered) { tip.remove() } @@ -313,7 +310,7 @@ class Tooltip extends BaseComponent { this._activeTrigger[TRIGGER_HOVER] = false this._queueCallback(complete, this.tip, this._isAnimated()) - this._hoverState = '' + this._isHovered = false } update() { @@ -521,15 +518,15 @@ class Tooltip extends BaseComponent { } _enter() { - if (this.getTipElement().classList.contains(CLASS_NAME_SHOW) || this._hoverState === HOVER_STATE_SHOW) { - this._hoverState = HOVER_STATE_SHOW + if (this.getTipElement().classList.contains(CLASS_NAME_SHOW) || this._isHovered) { + this._isHovered = true return } - this._hoverState = HOVER_STATE_SHOW + this._isHovered = true this._setTimeout(() => { - if (this._hoverState === HOVER_STATE_SHOW) { + if (this._isHovered) { this.show() } }, this._config.delay.show) @@ -540,10 +537,10 @@ class Tooltip extends BaseComponent { return } - this._hoverState = HOVER_STATE_OUT + this._isHovered = false this._setTimeout(() => { - if (this._hoverState === HOVER_STATE_OUT) { + if (!this._isHovered) { this.hide() } }, this._config.delay.hide) -- cgit v1.2.3 From 1f7b83203d893ba674f6a0c54481e84378276a19 Mon Sep 17 00:00:00 2001 From: GeoSot Date: Sun, 28 Nov 2021 14:18:59 +0200 Subject: Tooltip: simplify popper check --- 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 f03f9ef4d..fc96812b4 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -314,7 +314,7 @@ class Tooltip extends BaseComponent { } update() { - if (this._popper !== null) { + if (this._popper) { this._popper.update() } } -- cgit v1.2.3 From bd79d69a73a77172584baadf9aa36e2d2091160e Mon Sep 17 00:00:00 2001 From: GeoSot Date: Mon, 29 Nov 2021 16:16:42 +0200 Subject: Tooltip: a simple code-block position change --- js/src/tooltip.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index fc96812b4..5fd1927c9 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -274,27 +274,12 @@ class Tooltip extends BaseComponent { return } - const tip = this.getTipElement() - const complete = () => { - if (this._isWithActiveTrigger()) { - return - } - - if (!this._isHovered) { - tip.remove() - } - - this._element.removeAttribute('aria-describedby') - EventHandler.trigger(this._element, this.constructor.Event.HIDDEN) - - this._disposePopper() - } - const hideEvent = EventHandler.trigger(this._element, this.constructor.Event.HIDE) if (hideEvent.defaultPrevented) { return } + const tip = this.getTipElement() tip.classList.remove(CLASS_NAME_SHOW) // If this is a touch-enabled device we remove the extra @@ -309,6 +294,21 @@ class Tooltip extends BaseComponent { this._activeTrigger[TRIGGER_FOCUS] = false this._activeTrigger[TRIGGER_HOVER] = false + const complete = () => { + if (this._isWithActiveTrigger()) { + return + } + + if (!this._isHovered) { + tip.remove() + } + + this._element.removeAttribute('aria-describedby') + EventHandler.trigger(this._element, this.constructor.Event.HIDDEN) + + this._disposePopper() + } + this._queueCallback(complete, this.tip, this._isAnimated()) this._isHovered = false } -- cgit v1.2.3 From 385fea49e8a7c83f2e9655cd9453256aef254aaa Mon Sep 17 00:00:00 2001 From: GeoSot Date: Mon, 29 Nov 2021 16:25:12 +0200 Subject: Tooltip/Popover: add underscore prefix to protected functions --- js/src/tooltip.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 5fd1927c9..2f3acda38 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -181,7 +181,7 @@ class Tooltip extends BaseComponent { context._leave() } } else { - if (this.getTipElement().classList.contains(CLASS_NAME_SHOW)) { + if (this._getTipElement().classList.contains(CLASS_NAME_SHOW)) { this._leave() return } @@ -208,7 +208,7 @@ class Tooltip extends BaseComponent { throw new Error('Please use show on visible elements') } - if (!(this.isWithContent() && this._isEnabled)) { + if (!(this._isWithContent() && this._isEnabled)) { return } @@ -222,7 +222,7 @@ class Tooltip extends BaseComponent { return } - const tip = this.getTipElement() + const tip = this._getTipElement() this._element.setAttribute('aria-describedby', tip.getAttribute('id')) @@ -279,7 +279,7 @@ class Tooltip extends BaseComponent { return } - const tip = this.getTipElement() + const tip = this._getTipElement() tip.classList.remove(CLASS_NAME_SHOW) // If this is a touch-enabled device we remove the extra @@ -320,11 +320,11 @@ class Tooltip extends BaseComponent { } // Protected - isWithContent() { - return Boolean(this.getTitle()) + _isWithContent() { + return Boolean(this._getTitle()) } - getTipElement() { + _getTipElement() { if (!this.tip) { this.tip = this._createTipElement(this._getContentForTemplate()) } @@ -389,11 +389,11 @@ class Tooltip extends BaseComponent { _getContentForTemplate() { return { - [SELECTOR_TOOLTIP_INNER]: this.getTitle() + [SELECTOR_TOOLTIP_INNER]: this._getTitle() } } - getTitle() { + _getTitle() { return this._resolvePossibleFunction(this._config.title) || this._element.getAttribute('title') } @@ -518,7 +518,7 @@ class Tooltip extends BaseComponent { } _enter() { - if (this.getTipElement().classList.contains(CLASS_NAME_SHOW) || this._isHovered) { + if (this._getTipElement().classList.contains(CLASS_NAME_SHOW) || this._isHovered) { this._isHovered = true return } -- cgit v1.2.3 From 328f723008cc39292a9f355e2eafb0fd04740656 Mon Sep 17 00:00:00 2001 From: GeoSot Date: Tue, 7 Dec 2021 15:51:56 +0200 Subject: Tooltip: remove title attribute before show & add tests (#35456) --- js/src/tooltip.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 2f3acda38..19a9b3168 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -394,7 +394,7 @@ class Tooltip extends BaseComponent { } _getTitle() { - return this._resolvePossibleFunction(this._config.title) || this._element.getAttribute('title') + return this._config.title } // Private @@ -510,11 +510,17 @@ class Tooltip extends BaseComponent { } _fixTitle() { - const title = this._element.getAttribute('title') + const title = this._config.originalTitle - if (title && !this._element.getAttribute('aria-label') && !this._element.textContent) { + if (!title) { + return + } + + if (!this._element.getAttribute('aria-label') && !this._element.textContent) { this._element.setAttribute('aria-label', title) } + + this._element.removeAttribute('title') } _enter() { @@ -579,6 +585,8 @@ class Tooltip extends BaseComponent { } } + config.originalTitle = this._element.getAttribute('title') || '' + config.title = this._resolvePossibleFunction(config.title) || config.originalTitle if (typeof config.title === 'number') { config.title = config.title.toString() } -- cgit v1.2.3 From 886b940796b3595a03b44230ca8b78197c5ee1c5 Mon Sep 17 00:00:00 2001 From: GeoSot Date: Fri, 10 Dec 2021 18:18:18 +0200 Subject: Extract Component config functionality to a separate class (#33872) Co-authored-by: XhmikosR --- js/src/tooltip.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 19a9b3168..9c8e54c66 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -12,8 +12,7 @@ import { getElement, getUID, isRTL, - noop, - typeCheckConfig + noop } from './util/index' import { DefaultAllowlist } from './util/sanitizer' import EventHandler from './dom/event-handler' @@ -140,6 +139,10 @@ class Tooltip extends BaseComponent { return Default } + static get DefaultType() { + return DefaultType + } + static get NAME() { return NAME } @@ -148,10 +151,6 @@ class Tooltip extends BaseComponent { return Event } - static get DefaultType() { - return DefaultType - } - // Public enable() { this._isEnabled = true @@ -571,11 +570,16 @@ class Tooltip extends BaseComponent { } config = { - ...this.constructor.Default, ...dataAttributes, ...(typeof config === 'object' && config ? config : {}) } + config = this._mergeConfigObj(config) + config = this._configAfterMerge(config) + this._typeCheckConfig(config) + return config + } + _configAfterMerge(config) { config.container = config.container === false ? document.body : getElement(config.container) if (typeof config.delay === 'number') { @@ -595,7 +599,6 @@ class Tooltip extends BaseComponent { config.content = config.content.toString() } - typeCheckConfig(NAME, config, this.constructor.DefaultType) return config } -- cgit v1.2.3 From e0960b08e030f8c4c0c838c1dd0c392209d51f92 Mon Sep 17 00:00:00 2001 From: GeoSot Date: Wed, 15 Dec 2021 10:47:32 +0200 Subject: Tooltip: remove extraneous call to _getConfig() (#35540) BaseClass already initializes the config Co-authored-by: XhmikosR --- js/src/tooltip.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 9c8e54c66..94c3935bd 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -117,7 +117,7 @@ class Tooltip extends BaseComponent { throw new TypeError('Bootstrap\'s tooltips require Popper (https://popper.js.org)') } - super(element) + super(element, config) // Private this._isEnabled = true @@ -128,7 +128,6 @@ class Tooltip extends BaseComponent { this._templateFactory = null // Protected - this._config = this._getConfig(config) this.tip = null this._setListeners() -- cgit v1.2.3 From 65cf77ae3ef676a5d9e2ea640393ec8055e8b953 Mon Sep 17 00:00:00 2001 From: GeoSot Date: Tue, 21 Dec 2021 17:19:29 +0200 Subject: Popover/Tooltip: Fix vertical alignment on arrow of tip elements (#35527) Regression of #32692 Co-authored-by: XhmikosR --- js/src/tooltip.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 94c3935bd..aa54371e7 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -449,6 +449,16 @@ class Tooltip extends BaseComponent { options: { element: `.${this.constructor.NAME}-arrow` } + }, + { + name: 'preSetPlacement', + enabled: true, + phase: 'beforeMain', + fn: data => { + // Pre-set Popper's placement attribute in order to read the arrow sizes properly. + // Otherwise, Popper mixes up the width and height dimensions since the initial arrow style is for top placement + this._getTipElement().setAttribute('data-popper-placement', data.state.placement) + } } ] } @@ -624,7 +634,6 @@ class Tooltip extends BaseComponent { } // Static - static jQueryInterface(config) { return this.each(function () { const data = Tooltip.getOrCreateInstance(this, config) -- cgit v1.2.3 From 62d86c07f81dfae632742dbf62633e767bac8edd Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Fri, 29 Oct 2021 10:38:35 +0300 Subject: Rename variables --- js/src/tooltip.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index aa54371e7..32f9cb91c 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -254,12 +254,12 @@ class Tooltip extends BaseComponent { } const complete = () => { - const prevHoverState = this._isHovered + const previousHoverState = this._isHovered this._isHovered = false EventHandler.trigger(this._element, this.constructor.Event.SHOWN) - if (prevHoverState) { + if (previousHoverState) { this._leave() } } @@ -408,7 +408,7 @@ class Tooltip extends BaseComponent { const { offset } = this._config if (typeof offset === 'string') { - return offset.split(',').map(val => Number.parseInt(val, 10)) + return offset.split(',').map(value => Number.parseInt(value, 10)) } if (typeof offset === 'function') { @@ -572,9 +572,9 @@ class Tooltip extends BaseComponent { _getConfig(config) { const dataAttributes = Manipulator.getDataAttributes(this._element) - for (const dataAttr of Object.keys(dataAttributes)) { - if (DISALLOWED_ATTRIBUTES.has(dataAttr)) { - delete dataAttributes[dataAttr] + for (const dataAttribute of Object.keys(dataAttributes)) { + if (DISALLOWED_ATTRIBUTES.has(dataAttribute)) { + delete dataAttributes[dataAttribute] } } -- cgit v1.2.3 From 74f24cdf2458d917c7b7d8074706ec5823f4d166 Mon Sep 17 00:00:00 2001 From: GeoSot Date: Sun, 30 Jan 2022 17:39:03 +0200 Subject: More tooltip refactoring (#35546) * Tooltip.js: move `shown` check to method * Tooltip.js: move Popper's creation to method * Tooltip.js: merge checks before `hide` * Tooltip.js: minor refactoring on `toggle` method --- js/src/tooltip.js | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 32f9cb91c..ef5b9fa82 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -178,14 +178,16 @@ class Tooltip extends BaseComponent { } else { context._leave() } - } else { - if (this._getTipElement().classList.contains(CLASS_NAME_SHOW)) { - this._leave() - return - } - this._enter() + return + } + + if (this._isShown()) { + this._leave() + return } + + this._enter() } dispose() { @@ -234,11 +236,7 @@ class Tooltip extends BaseComponent { if (this._popper) { this._popper.update() } else { - const placement = typeof this._config.placement === 'function' ? - this._config.placement.call(this, tip, this._element) : - this._config.placement - const attachment = AttachmentMap[placement.toUpperCase()] - this._popper = Popper.createPopper(this._element, tip, this._getPopperConfig(attachment)) + this._createPopper(tip) } tip.classList.add(CLASS_NAME_SHOW) @@ -268,7 +266,7 @@ class Tooltip extends BaseComponent { } hide() { - if (!this._popper) { + if (!this._isShown()) { return } @@ -291,6 +289,7 @@ class Tooltip extends BaseComponent { this._activeTrigger[TRIGGER_CLICK] = false this._activeTrigger[TRIGGER_FOCUS] = false this._activeTrigger[TRIGGER_HOVER] = false + this._isHovered = false const complete = () => { if (this._isWithActiveTrigger()) { @@ -308,7 +307,6 @@ class Tooltip extends BaseComponent { } this._queueCallback(complete, this.tip, this._isAnimated()) - this._isHovered = false } update() { @@ -356,7 +354,7 @@ class Tooltip extends BaseComponent { setContent(content) { let isShown = false if (this.tip) { - isShown = this.tip.classList.contains(CLASS_NAME_SHOW) + isShown = this._isShown() this.tip.remove() this.tip = null } @@ -404,6 +402,18 @@ class Tooltip extends BaseComponent { return this._config.animation || (this.tip && this.tip.classList.contains(CLASS_NAME_FADE)) } + _isShown() { + return this.tip && this.tip.classList.contains(CLASS_NAME_SHOW) + } + + _createPopper(tip) { + const placement = typeof this._config.placement === 'function' ? + this._config.placement.call(this, tip, this._element) : + this._config.placement + const attachment = AttachmentMap[placement.toUpperCase()] + this._popper = Popper.createPopper(this._element, tip, this._getPopperConfig(attachment)) + } + _getOffset() { const { offset } = this._config @@ -532,7 +542,7 @@ class Tooltip extends BaseComponent { } _enter() { - if (this._getTipElement().classList.contains(CLASS_NAME_SHOW) || this._isHovered) { + if (this._isShown() || this._isHovered) { this._isHovered = true return } -- cgit v1.2.3 From 407af8ac7f9296627aebc1e4c5d0ee948f8be1f3 Mon Sep 17 00:00:00 2001 From: GeoSot Date: Sat, 19 Feb 2022 15:10:47 +0200 Subject: Make event name helper and use it on tooltip & popover to reduce dist sizes (#35856) * feat: create eventName getter function in baseComponent * refactor: use `eventName` getter on tooltip & popover --- js/src/tooltip.js | 59 +++++++++++++++++++++---------------------------------- 1 file changed, 22 insertions(+), 37 deletions(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index ef5b9fa82..5cf56ce6e 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -6,14 +6,7 @@ */ import * as Popper from '@popperjs/core' -import { - defineJQueryPlugin, - findShadowRoot, - getElement, - getUID, - isRTL, - noop -} from './util/index' +import { defineJQueryPlugin, findShadowRoot, getElement, getUID, isRTL, noop } from './util/index' import { DefaultAllowlist } from './util/sanitizer' import EventHandler from './dom/event-handler' import Manipulator from './dom/manipulator' @@ -25,8 +18,6 @@ import TemplateFactory from './util/template-factory' */ const NAME = 'tooltip' -const DATA_KEY = 'bs.tooltip' -const EVENT_KEY = `.${DATA_KEY}` const DISALLOWED_ATTRIBUTES = new Set(['sanitize', 'allowList', 'sanitizeFn']) const CLASS_NAME_FADE = 'fade' @@ -43,6 +34,17 @@ const TRIGGER_FOCUS = 'focus' const TRIGGER_CLICK = 'click' const TRIGGER_MANUAL = 'manual' +const EVENT_HIDE = 'hide' +const EVENT_HIDDEN = 'hidden' +const EVENT_SHOW = 'show' +const EVENT_SHOWN = 'shown' +const EVENT_INSERTED = 'inserted' +const EVENT_CLICK = 'click' +const EVENT_FOCUSIN = 'focusin' +const EVENT_FOCUSOUT = 'focusout' +const EVENT_MOUSEENTER = 'mouseenter' +const EVENT_MOUSELEAVE = 'mouseleave' + const AttachmentMap = { AUTO: 'auto', TOP: 'top', @@ -94,19 +96,6 @@ const DefaultType = { popperConfig: '(null|object|function)' } -const Event = { - HIDE: `hide${EVENT_KEY}`, - HIDDEN: `hidden${EVENT_KEY}`, - SHOW: `show${EVENT_KEY}`, - SHOWN: `shown${EVENT_KEY}`, - INSERTED: `inserted${EVENT_KEY}`, - CLICK: `click${EVENT_KEY}`, - FOCUSIN: `focusin${EVENT_KEY}`, - FOCUSOUT: `focusout${EVENT_KEY}`, - MOUSEENTER: `mouseenter${EVENT_KEY}`, - MOUSELEAVE: `mouseleave${EVENT_KEY}` -} - /** * Class definition */ @@ -146,10 +135,6 @@ class Tooltip extends BaseComponent { return NAME } - static get Event() { - return Event - } - // Public enable() { this._isEnabled = true @@ -212,7 +197,7 @@ class Tooltip extends BaseComponent { return } - const showEvent = EventHandler.trigger(this._element, this.constructor.Event.SHOW) + const showEvent = EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOW)) const shadowRoot = findShadowRoot(this._element) const isInTheDom = shadowRoot === null ? this._element.ownerDocument.documentElement.contains(this._element) : @@ -230,7 +215,7 @@ class Tooltip extends BaseComponent { if (!this._element.ownerDocument.documentElement.contains(this.tip)) { container.append(tip) - EventHandler.trigger(this._element, this.constructor.Event.INSERTED) + EventHandler.trigger(this._element, this.constructor.eventName(EVENT_INSERTED)) } if (this._popper) { @@ -255,7 +240,7 @@ class Tooltip extends BaseComponent { const previousHoverState = this._isHovered this._isHovered = false - EventHandler.trigger(this._element, this.constructor.Event.SHOWN) + EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOWN)) if (previousHoverState) { this._leave() @@ -270,7 +255,7 @@ class Tooltip extends BaseComponent { return } - const hideEvent = EventHandler.trigger(this._element, this.constructor.Event.HIDE) + const hideEvent = EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDE)) if (hideEvent.defaultPrevented) { return } @@ -301,7 +286,7 @@ class Tooltip extends BaseComponent { } this._element.removeAttribute('aria-describedby') - EventHandler.trigger(this._element, this.constructor.Event.HIDDEN) + EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDDEN)) this._disposePopper() } @@ -484,14 +469,14 @@ class Tooltip extends BaseComponent { for (const trigger of triggers) { if (trigger === 'click') { - EventHandler.on(this._element, this.constructor.Event.CLICK, this._config.selector, event => this.toggle(event)) + EventHandler.on(this._element, this.constructor.eventName(EVENT_CLICK), this._config.selector, event => this.toggle(event)) } else if (trigger !== TRIGGER_MANUAL) { const eventIn = trigger === TRIGGER_HOVER ? - this.constructor.Event.MOUSEENTER : - this.constructor.Event.FOCUSIN + this.constructor.eventName(EVENT_MOUSEENTER) : + this.constructor.eventName(EVENT_FOCUSIN) const eventOut = trigger === TRIGGER_HOVER ? - this.constructor.Event.MOUSELEAVE : - this.constructor.Event.FOCUSOUT + this.constructor.eventName(EVENT_MOUSELEAVE) : + this.constructor.eventName(EVENT_FOCUSOUT) EventHandler.on(this._element, eventIn, this._config.selector, event => { const context = this._initializeOnDelegatedTarget(event) -- cgit v1.2.3 From e4b62a920a5ed9c48c46865f987702fa67369ae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B8=D0=BB=D1=8F=D0=BD=20=D0=9F=D0=B0=D0=BB=D0=B0?= =?UTF-8?q?=D1=83=D0=B7=D0=BE=D0=B2?= Date: Thu, 27 Jan 2022 10:43:27 +0200 Subject: src/tooltip.js Optimization Util.findShadowRoot() returns either null or an object. It cannot return falsy, which allows this optimization. --- js/src/tooltip.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 5cf56ce6e..db626048f 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -199,9 +199,7 @@ class Tooltip extends BaseComponent { const showEvent = EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOW)) const shadowRoot = findShadowRoot(this._element) - const isInTheDom = shadowRoot === null ? - this._element.ownerDocument.documentElement.contains(this._element) : - shadowRoot.contains(this._element) + const isInTheDom = (shadowRoot || this._element.ownerDocument.documentElement).contains(this._element) if (showEvent.defaultPrevented || !isInTheDom) { return -- cgit v1.2.3 From f7e8ca91e03165abb82d4c82555dc4ef96340cc9 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Fri, 6 May 2022 23:57:58 +0300 Subject: Prepare v5.2.0-beta1 --- 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 db626048f..a7368d085 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -1,6 +1,6 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): tooltip.js + * Bootstrap (v5.2.0-beta1): tooltip.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ -- cgit v1.2.3 From c137d11aa2df111e2a42bc42295576fdd366fd68 Mon Sep 17 00:00:00 2001 From: "louismaxime.piton" Date: Thu, 19 May 2022 15:35:44 +0200 Subject: Re-ordering js default objects --- js/src/tooltip.js | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index a7368d085..92770091d 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -54,46 +54,46 @@ const AttachmentMap = { } const Default = { + allowList: DefaultAllowlist, animation: true, - template: '', - trigger: 'hover focus', - title: '', + boundary: 'clippingParents', + container: false, + customClass: '', delay: 0, + fallbackPlacements: ['top', 'right', 'bottom', 'left'], html: false, - selector: false, - placement: 'top', offset: [0, 0], - container: false, - fallbackPlacements: ['top', 'right', 'bottom', 'left'], - boundary: 'clippingParents', - customClass: '', + placement: 'top', + popperConfig: null, sanitize: true, sanitizeFn: null, - allowList: DefaultAllowlist, - popperConfig: null + selector: false, + template: '', + title: '', + trigger: 'hover focus' } const DefaultType = { + allowList: 'object', animation: 'boolean', - template: 'string', - title: '(string|element|function)', - trigger: 'string', + boundary: '(string|element)', + container: '(string|element|boolean)', + customClass: '(string|function)', delay: '(number|object)', + fallbackPlacements: 'array', html: 'boolean', - selector: '(string|boolean)', - placement: '(string|function)', offset: '(array|string|function)', - container: '(string|element|boolean)', - fallbackPlacements: 'array', - boundary: '(string|element)', - customClass: '(string|function)', + placement: '(string|function)', + popperConfig: '(null|object|function)', sanitize: 'boolean', sanitizeFn: '(null|function)', - allowList: 'object', - popperConfig: '(null|object|function)' + selector: '(string|boolean)', + template: 'string', + title: '(string|element|function)', + trigger: 'string' } /** -- cgit v1.2.3 From 4f4b42dd14dd9a59df6536585142864eea4383b9 Mon Sep 17 00:00:00 2001 From: GeoSot Date: Mon, 27 Jun 2022 12:58:27 +0300 Subject: Force tooltip and popover to recreate content every time it opens (#35679) --- js/src/tooltip.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 92770091d..650bf2b09 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -115,6 +115,7 @@ class Tooltip extends BaseComponent { this._activeTrigger = {} this._popper = null this._templateFactory = null + this._newContent = null // Protected this.tip = null @@ -205,6 +206,12 @@ class Tooltip extends BaseComponent { return } + // todo v6 remove this OR make it optional + if (this.tip) { + this.tip.remove() + this.tip = null + } + const tip = this._getTipElement() this._element.setAttribute('aria-describedby', tip.getAttribute('id')) @@ -219,7 +226,7 @@ class Tooltip extends BaseComponent { if (this._popper) { this._popper.update() } else { - this._createPopper(tip) + this._popper = this._createPopper(tip) } tip.classList.add(CLASS_NAME_SHOW) @@ -305,7 +312,7 @@ class Tooltip extends BaseComponent { _getTipElement() { if (!this.tip) { - this.tip = this._createTipElement(this._getContentForTemplate()) + this.tip = this._createTipElement(this._newContent || this._getContentForTemplate()) } return this.tip @@ -335,17 +342,11 @@ class Tooltip extends BaseComponent { } setContent(content) { - let isShown = false - if (this.tip) { - isShown = this._isShown() + this._newContent = content + if (this._isShown()) { this.tip.remove() this.tip = null - } - - this._disposePopper() - this.tip = this._createTipElement(content) - - if (isShown) { + this._disposePopper() this.show() } } @@ -373,7 +374,7 @@ class Tooltip extends BaseComponent { } _getTitle() { - return this._config.title + return this._resolvePossibleFunction(this._config.title) || this._config.originalTitle } // Private @@ -394,7 +395,7 @@ class Tooltip extends BaseComponent { this._config.placement.call(this, tip, this._element) : this._config.placement const attachment = AttachmentMap[placement.toUpperCase()] - this._popper = Popper.createPopper(this._element, tip, this._getPopperConfig(attachment)) + return Popper.createPopper(this._element, tip, this._getPopperConfig(attachment)) } _getOffset() { @@ -592,7 +593,6 @@ class Tooltip extends BaseComponent { } config.originalTitle = this._element.getAttribute('title') || '' - config.title = this._resolvePossibleFunction(config.title) || config.originalTitle if (typeof config.title === 'number') { config.title = config.title.toString() } -- cgit v1.2.3 From 3f324eed02f24f817e7d75bc7d37c210644a06ee Mon Sep 17 00:00:00 2001 From: Nathan Walters Date: Tue, 5 Jul 2022 22:15:50 -0700 Subject: Handle non-empty whitespace `textContent` in Tooltip trigger (#36588) --- 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 650bf2b09..f8d97f240 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -518,7 +518,7 @@ class Tooltip extends BaseComponent { return } - if (!this._element.getAttribute('aria-label') && !this._element.textContent) { + if (!this._element.getAttribute('aria-label') && !this._element.textContent.trim()) { this._element.setAttribute('aria-label', title) } -- cgit v1.2.3 From ed2690608ec31fe557929de33bbb473ecdb0a03e Mon Sep 17 00:00:00 2001 From: Louis-Maxime Piton Date: Tue, 12 Jul 2022 01:29:30 +0200 Subject: Fix on #35679 (#36668) * Fix * . --- js/src/tooltip.js | 2 -- 1 file changed, 2 deletions(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index f8d97f240..40158c4d6 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -344,8 +344,6 @@ class Tooltip extends BaseComponent { setContent(content) { this._newContent = content if (this._isShown()) { - this.tip.remove() - this.tip = null this._disposePopper() this.show() } -- cgit v1.2.3 From edf9c40956d19e6ab3f9151bfe0dfac6be06fa21 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Tue, 19 Jul 2022 18:43:58 +0300 Subject: Release v5.2.0 (#36768) * Bump version to 5.2.0 * Dist * Update masthead.html --- 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 40158c4d6..54ec0367e 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -1,6 +1,6 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.2.0-beta1): tooltip.js + * Bootstrap (v5.2.0): tooltip.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ -- cgit v1.2.3 From dfae892801ffc194de6aec34d543d908db3dd8e1 Mon Sep 17 00:00:00 2001 From: GeoSot Date: Wed, 27 Jul 2022 17:40:05 +0300 Subject: Re-set tooltip title, on disposal (#36751) fix(reg): Re-set tooltip title, on disposal --- js/src/tooltip.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 54ec0367e..2c5f03a29 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -185,6 +185,10 @@ class Tooltip extends BaseComponent { this.tip.remove() } + if (this._config.originalTitle) { + this._element.setAttribute('title', this._config.originalTitle) + } + this._disposePopper() super.dispose() } -- cgit v1.2.3 From 949456984aa21536afd35eddf7ea38b3648830a3 Mon Sep 17 00:00:00 2001 From: GeoSot Date: Wed, 7 Sep 2022 11:47:06 +0300 Subject: Fix tooltip manual toggling (#37086) partial regression of SHA: 9b9372e8ddd60413f3d9a582bd5481586d119d8d --- js/src/tooltip.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 2c5f03a29..cb805dad8 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -111,7 +111,7 @@ class Tooltip extends BaseComponent { // Private this._isEnabled = true this._timeout = 0 - this._isHovered = false + this._isHovered = null this._activeTrigger = {} this._popper = null this._templateFactory = null @@ -246,14 +246,13 @@ class Tooltip extends BaseComponent { } const complete = () => { - const previousHoverState = this._isHovered - - this._isHovered = false EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOWN)) - if (previousHoverState) { + if (this._isHovered === false) { this._leave() } + + this._isHovered = false } this._queueCallback(complete, this.tip, this._isAnimated()) @@ -283,7 +282,7 @@ class Tooltip extends BaseComponent { this._activeTrigger[TRIGGER_CLICK] = false this._activeTrigger[TRIGGER_FOCUS] = false this._activeTrigger[TRIGGER_HOVER] = false - this._isHovered = false + this._isHovered = null // it is a trick to support manual triggering const complete = () => { if (this._isWithActiveTrigger()) { -- cgit v1.2.3 From 23e50829f958ea1d741d63e2781716be037e4644 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Wed, 7 Sep 2022 18:31:39 +0300 Subject: Release v5.2.1 (#37098) * Bump version to v5.2.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 cb805dad8..e30701efc 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -1,6 +1,6 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.2.0): tooltip.js + * Bootstrap (v5.2.1): tooltip.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ -- cgit v1.2.3 From 3bd57564140ef3953582a80e8f1084d81bdb5977 Mon Sep 17 00:00:00 2001 From: GeoSot Date: Wed, 14 Sep 2022 16:24:37 +0300 Subject: fix: add trick to support tooltip selector usage on dynamic created tooltips that utilize `title` attribute (#36914) --- js/src/tooltip.js | 49 ++++++++++++++++++------------------------------- 1 file changed, 18 insertions(+), 31 deletions(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index e30701efc..86c6056d8 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -121,6 +121,10 @@ class Tooltip extends BaseComponent { this.tip = null this._setListeners() + + if (!this._config.selector) { + this._fixTitle() + } } // Getters @@ -149,25 +153,12 @@ class Tooltip extends BaseComponent { this._isEnabled = !this._isEnabled } - toggle(event) { + toggle() { if (!this._isEnabled) { return } - if (event) { - const context = this._initializeOnDelegatedTarget(event) - - context._activeTrigger.click = !context._activeTrigger.click - - if (context._isWithActiveTrigger()) { - context._enter() - } else { - context._leave() - } - - return - } - + this._activeTrigger.click = !this._activeTrigger.click if (this._isShown()) { this._leave() return @@ -185,8 +176,8 @@ class Tooltip extends BaseComponent { this.tip.remove() } - if (this._config.originalTitle) { - this._element.setAttribute('title', this._config.originalTitle) + if (this._element.getAttribute('data-bs-original-title')) { + this._element.setAttribute('title', this._element.getAttribute('data-bs-original-title')) } this._disposePopper() @@ -375,7 +366,7 @@ class Tooltip extends BaseComponent { } _getTitle() { - return this._resolvePossibleFunction(this._config.title) || this._config.originalTitle + return this._resolvePossibleFunction(this._config.title) || this._element.getAttribute('data-bs-original-title') } // Private @@ -469,7 +460,10 @@ class Tooltip extends BaseComponent { for (const trigger of triggers) { if (trigger === 'click') { - EventHandler.on(this._element, this.constructor.eventName(EVENT_CLICK), this._config.selector, event => this.toggle(event)) + EventHandler.on(this._element, this.constructor.eventName(EVENT_CLICK), this._config.selector, event => { + const context = this._initializeOnDelegatedTarget(event) + context.toggle() + }) } else if (trigger !== TRIGGER_MANUAL) { const eventIn = trigger === TRIGGER_HOVER ? this.constructor.eventName(EVENT_MOUSEENTER) : @@ -500,20 +494,10 @@ class Tooltip extends BaseComponent { } EventHandler.on(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler) - - if (this._config.selector) { - this._config = { - ...this._config, - trigger: 'manual', - selector: '' - } - } else { - this._fixTitle() - } } _fixTitle() { - const title = this._config.originalTitle + const title = this._element.getAttribute('title') if (!title) { return @@ -523,6 +507,7 @@ class Tooltip extends BaseComponent { this._element.setAttribute('aria-label', title) } + this._element.setAttribute('data-bs-original-title', title) // DO NOT USE IT. Is only for backwards compatibility this._element.removeAttribute('title') } @@ -593,7 +578,6 @@ class Tooltip extends BaseComponent { } } - config.originalTitle = this._element.getAttribute('title') || '' if (typeof config.title === 'number') { config.title = config.title.toString() } @@ -614,6 +598,9 @@ class Tooltip extends BaseComponent { } } + config.selector = false + config.trigger = 'manual' + // In the future can be replaced with: // const keysWithDifferentValues = Object.entries(this._config).filter(entry => this.constructor.Default[entry[0]] !== this._config[entry[0]]) // `Object.fromEntries(keysWithDifferentValues)` -- cgit v1.2.3 From 961d5ff9844372a4e294980c667bbe7e0651cdeb Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Mon, 3 Oct 2022 10:44:02 +0300 Subject: Release v5.2.2 (#37236) * Bump version to v5.2.2 * 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 86c6056d8..e01f0a4ae 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -1,6 +1,6 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.2.1): tooltip.js + * Bootstrap (v5.2.2): tooltip.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ -- cgit v1.2.3 From 01dc2f51003947408b1237fd4c58c0f078596378 Mon Sep 17 00:00:00 2001 From: GeoSot Date: Thu, 6 Oct 2022 11:31:38 +0300 Subject: fix tooltip/popper disposal inconsistencies (#37235) --- js/src/tooltip.js | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index e01f0a4ae..70198c81b 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -172,10 +172,6 @@ class Tooltip extends BaseComponent { 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')) { 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 - if (this.tip) { - this.tip.remove() - this.tip = null - } + this._disposePopper() const tip = this._getTipElement() @@ -218,11 +211,7 @@ class Tooltip extends BaseComponent { 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) @@ -281,13 +270,11 @@ class Tooltip extends BaseComponent { } if (!this._isHovered) { - tip.remove() + this._disposePopper() } this._element.removeAttribute('aria-describedby') EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDDEN)) - - this._disposePopper() } this._queueCallback(complete, this.tip, this._isAnimated()) @@ -612,6 +599,11 @@ class Tooltip extends BaseComponent { this._popper.destroy() this._popper = null } + + if (this.tip) { + this.tip.remove() + this.tip = null + } } // Static -- cgit v1.2.3 From 4cb046a6b8b37a0f328fa5b86fbd573ca3f0dc33 Mon Sep 17 00:00:00 2001 From: GeoSot Date: Fri, 7 Oct 2022 15:25:00 +0300 Subject: Boost `execute` function, being able to handle arguments (#36652) --- js/src/tooltip.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 70198c81b..a3f3377c0 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -6,7 +6,7 @@ */ import * as Popper from '@popperjs/core' -import { defineJQueryPlugin, findShadowRoot, getElement, getUID, isRTL, noop } from './util/index' +import { defineJQueryPlugin, execute, findShadowRoot, getElement, getUID, isRTL, noop } from './util/index' import { DefaultAllowlist } from './util/sanitizer' import EventHandler from './dom/event-handler' import Manipulator from './dom/manipulator' @@ -370,9 +370,7 @@ class Tooltip extends BaseComponent { } _createPopper(tip) { - const placement = typeof this._config.placement === 'function' ? - this._config.placement.call(this, tip, this._element) : - this._config.placement + const placement = execute(this._config.placement, [this, tip, this._element]) const attachment = AttachmentMap[placement.toUpperCase()] return Popper.createPopper(this._element, tip, this._getPopperConfig(attachment)) } @@ -392,7 +390,7 @@ class Tooltip extends BaseComponent { } _resolvePossibleFunction(arg) { - return typeof arg === 'function' ? arg.call(this._element) : arg + return execute(arg, [this._element]) } _getPopperConfig(attachment) { @@ -438,7 +436,7 @@ class Tooltip extends BaseComponent { return { ...defaultBsPopperConfig, - ...(typeof this._config.popperConfig === 'function' ? this._config.popperConfig(defaultBsPopperConfig) : this._config.popperConfig) + ...execute(this._config.popperConfig, [defaultBsPopperConfig]) } } -- cgit v1.2.3 From aa9d32dd153ed16943ad8be5e8795afaad24d0cf Mon Sep 17 00:00:00 2001 From: GeoSot Date: Wed, 26 Oct 2022 08:26:51 +0300 Subject: Use explicit imports in our javascript source files (#36854) --- js/src/tooltip.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index a3f3377c0..02d11363a 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -6,12 +6,12 @@ */ import * as Popper from '@popperjs/core' -import { defineJQueryPlugin, execute, findShadowRoot, getElement, getUID, isRTL, noop } from './util/index' -import { DefaultAllowlist } from './util/sanitizer' -import EventHandler from './dom/event-handler' -import Manipulator from './dom/manipulator' -import BaseComponent from './base-component' -import TemplateFactory from './util/template-factory' +import { defineJQueryPlugin, execute, findShadowRoot, getElement, getUID, isRTL, noop } from './util/index.js' +import { DefaultAllowlist } from './util/sanitizer.js' +import EventHandler from './dom/event-handler.js' +import Manipulator from './dom/manipulator.js' +import BaseComponent from './base-component.js' +import TemplateFactory from './util/template-factory.js' /** * Constants -- cgit v1.2.3 From 2fde88c20071f1e766703f78a25ebc431da9e1d8 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Sun, 13 Nov 2022 09:19:11 +0200 Subject: Use `Object.entries` in more places (#37482) --- js/src/tooltip.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 02d11363a..562b52db0 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -577,9 +577,9 @@ class Tooltip extends BaseComponent { _getDelegateConfig() { const config = {} - for (const key in this._config) { - if (this.constructor.Default[key] !== this._config[key]) { - config[key] = this._config[key] + for (const [key, value] of Object.entries(this._config)) { + if (this.constructor.Default[key] !== value) { + config[key] = value } } -- cgit v1.2.3 From 7e3074c16540eacea303266fdf235aecdd9cf5c3 Mon Sep 17 00:00:00 2001 From: GeoSot Date: Thu, 6 Oct 2022 11:31:38 +0300 Subject: fix tooltip/popper disposal inconsistencies (#37235) --- js/src/tooltip.js | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index e01f0a4ae..70198c81b 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -172,10 +172,6 @@ class Tooltip extends BaseComponent { 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')) { 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 - if (this.tip) { - this.tip.remove() - this.tip = null - } + this._disposePopper() const tip = this._getTipElement() @@ -218,11 +211,7 @@ class Tooltip extends BaseComponent { 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) @@ -281,13 +270,11 @@ class Tooltip extends BaseComponent { } if (!this._isHovered) { - tip.remove() + this._disposePopper() } this._element.removeAttribute('aria-describedby') EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDDEN)) - - this._disposePopper() } this._queueCallback(complete, this.tip, this._isAnimated()) @@ -612,6 +599,11 @@ class Tooltip extends BaseComponent { this._popper.destroy() this._popper = null } + + if (this.tip) { + this.tip.remove() + this.tip = null + } } // Static -- cgit v1.2.3 From 39589472f709ddf7d614ffd4f0ab1a50e542ac91 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Mon, 21 Nov 2022 20:15:33 +0200 Subject: Bump version to 5.2.3 --- 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 70198c81b..748a0e198 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -1,6 +1,6 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.2.2): tooltip.js + * Bootstrap (v5.2.3): tooltip.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ -- cgit v1.2.3 From cf9454caa00872899215603e5e036d9a824b1b11 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Sat, 24 Dec 2022 18:37:22 +0200 Subject: Release v5.3.0-alpha1 (#37661) * Bump version to 5.3.0-alpha1 * Dist * Add docs versions updates * Update note in homepage hero Co-authored-by: Mark Otto --- 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 85c4a39c8..e152ec214 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -1,6 +1,6 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.2.3): tooltip.js + * Bootstrap (v5.3.0-alpha1): tooltip.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ -- cgit v1.2.3 From ab049cd4a02650ca95d490217f93bd628f9295a6 Mon Sep 17 00:00:00 2001 From: GeoSot Date: Wed, 22 Mar 2023 09:12:33 +0200 Subject: Remove version comment from JavaScript src files (#38294) --- 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 e152ec214..87511edef 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -1,6 +1,6 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.3.0-alpha1): tooltip.js + * Bootstrap tooltip.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ -- cgit v1.2.3 From d533e6f33de2a26a0b7bf5a577eb5c120e51face Mon Sep 17 00:00:00 2001 From: kyletsang <6854874+kyletsang@users.noreply.github.com> Date: Tue, 28 Feb 2023 23:32:58 -0800 Subject: Fix tooltip body placement with variation placements --- 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 87511edef..ff1db974f 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -62,7 +62,7 @@ const Default = { delay: 0, fallbackPlacements: ['top', 'right', 'bottom', 'left'], html: false, - offset: [0, 0], + offset: [0, 6], placement: 'top', popperConfig: null, sanitize: true, -- cgit v1.2.3 From ae43f0c48bf7acede8a325b24197001fe2b2f416 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Wed, 29 Mar 2023 20:49:30 +0300 Subject: Tweak and re-organize ESLint config (#38369) * Tweak and re-organize ESLint config * merge individual configs to the root config * enable more eslint-plugin-import rules * lint markdown files * Lint --- js/src/tooltip.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index ff1db974f..125281157 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -6,11 +6,11 @@ */ import * as Popper from '@popperjs/core' -import { defineJQueryPlugin, execute, findShadowRoot, getElement, getUID, isRTL, noop } from './util/index.js' -import { DefaultAllowlist } from './util/sanitizer.js' +import BaseComponent from './base-component.js' import EventHandler from './dom/event-handler.js' import Manipulator from './dom/manipulator.js' -import BaseComponent from './base-component.js' +import { defineJQueryPlugin, execute, findShadowRoot, getElement, getUID, isRTL, noop } from './util/index.js' +import { DefaultAllowlist } from './util/sanitizer.js' import TemplateFactory from './util/template-factory.js' /** @@ -197,7 +197,7 @@ class Tooltip extends BaseComponent { return } - // todo v6 remove this OR make it optional + // TODO: v6 remove this or make it optional this._disposePopper() const tip = this._getTipElement() @@ -302,13 +302,13 @@ class Tooltip extends BaseComponent { _createTipElement(content) { const tip = this._getTemplateFactory(content).toHtml() - // todo: remove this check on v6 + // TODO: remove this check in v6 if (!tip) { return null } tip.classList.remove(CLASS_NAME_FADE, CLASS_NAME_SHOW) - // todo: on v6 the following can be achieved with CSS only + // TODO: v6 the following can be achieved with CSS only tip.classList.add(`bs-${this.constructor.NAME}-auto`) const tipId = getUID(this.constructor.NAME).toString() -- cgit v1.2.3 From 40c6d8a4bc9813e5c54cf7753b1f0785fed92715 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 Feb 2024 21:46:52 +0200 Subject: Build(deps-dev): Bump eslint-config-xo from 0.43.1 to 0.44.0 (#39651) * Build(deps-dev): Bump eslint-config-xo from 0.43.1 to 0.44.0 Bumps [eslint-config-xo](https://github.com/xojs/eslint-config-xo) from 0.43.1 to 0.44.0. - [Release notes](https://github.com/xojs/eslint-config-xo/releases) - [Commits](https://github.com/xojs/eslint-config-xo/compare/v0.43.1...v0.44.0) --- updated-dependencies: - dependency-name: eslint-config-xo dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Update .eslintrc.json * Update .eslintrc.json * autofix --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: XhmikosR --- js/src/tooltip.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 125281157..bcdc18f5d 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -9,7 +9,9 @@ import * as Popper from '@popperjs/core' import BaseComponent from './base-component.js' import EventHandler from './dom/event-handler.js' import Manipulator from './dom/manipulator.js' -import { defineJQueryPlugin, execute, findShadowRoot, getElement, getUID, isRTL, noop } from './util/index.js' +import { + defineJQueryPlugin, execute, findShadowRoot, getElement, getUID, isRTL, noop +} from './util/index.js' import { DefaultAllowlist } from './util/sanitizer.js' import TemplateFactory from './util/template-factory.js' -- cgit v1.2.3 From 953b4b6c1b67e120235fc19f565444a0f7a97a76 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Mon, 4 Mar 2024 20:58:00 +0200 Subject: Fix various redirects --- 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 bcdc18f5d..6a6cfeff2 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -105,7 +105,7 @@ const DefaultType = { class Tooltip extends BaseComponent { constructor(element, config) { if (typeof Popper === 'undefined') { - throw new TypeError('Bootstrap\'s tooltips require Popper (https://popper.js.org)') + throw new TypeError('Bootstrap\'s tooltips require Popper (https://popper.js.org/docs/v2/)') } super(element, config) -- cgit v1.2.3 From 16d80a4ff7b42da57215783cc8ff85d6f0627630 Mon Sep 17 00:00:00 2001 From: Nathan Sarang-Walters Date: Thu, 18 Jul 2024 22:05:21 -0700 Subject: Fix `this` reference for JavaScript functions (#38725) --- js/src/tooltip.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/src/tooltip.js') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 6a6cfeff2..92d455349 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -392,7 +392,7 @@ class Tooltip extends BaseComponent { } _resolvePossibleFunction(arg) { - return execute(arg, [this._element]) + return execute(arg, [this._element, this._element]) } _getPopperConfig(attachment) { @@ -438,7 +438,7 @@ class Tooltip extends BaseComponent { return { ...defaultBsPopperConfig, - ...execute(this._config.popperConfig, [defaultBsPopperConfig]) + ...execute(this._config.popperConfig, [undefined, defaultBsPopperConfig]) } } -- cgit v1.2.3