aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/twbs/bootstrap/js/dist/tooltip.js
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/twbs/bootstrap/js/dist/tooltip.js')
-rw-r--r--vendor/twbs/bootstrap/js/dist/tooltip.js131
1 files changed, 55 insertions, 76 deletions
diff --git a/vendor/twbs/bootstrap/js/dist/tooltip.js b/vendor/twbs/bootstrap/js/dist/tooltip.js
index 9f8380086..5a4ac0208 100644
--- a/vendor/twbs/bootstrap/js/dist/tooltip.js
+++ b/vendor/twbs/bootstrap/js/dist/tooltip.js
@@ -1,13 +1,13 @@
/*!
- * Bootstrap tooltip.js v5.1.1 (https://getbootstrap.com/)
+ * Bootstrap tooltip.js v5.0.2 (https://getbootstrap.com/)
* Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
(function (global, factory) {
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@popperjs/core'), require('./dom/data.js'), require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('./dom/selector-engine.js'), require('./base-component.js')) :
- typeof define === 'function' && define.amd ? define(['@popperjs/core', './dom/data', './dom/event-handler', './dom/manipulator', './dom/selector-engine', './base-component'], factory) :
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Tooltip = factory(global.Popper, global.Data, global.EventHandler, global.Manipulator, global.SelectorEngine, global.Base));
-}(this, (function (Popper, Data, EventHandler, Manipulator, SelectorEngine, BaseComponent) { 'use strict';
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@popperjs/core'), require('./dom/selector-engine.js'), require('./dom/data.js'), require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('./base-component.js')) :
+ typeof define === 'function' && define.amd ? define(['@popperjs/core', './dom/selector-engine', './dom/data', './dom/event-handler', './dom/manipulator', './base-component'], factory) :
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Tooltip = factory(global.Popper, global.SelectorEngine, global.Data, global.EventHandler, global.Manipulator, global.Base));
+}(this, (function (Popper, SelectorEngine, Data, EventHandler, Manipulator, BaseComponent) { 'use strict';
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -32,18 +32,19 @@
}
var Popper__namespace = /*#__PURE__*/_interopNamespace(Popper);
+ var SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine);
var Data__default = /*#__PURE__*/_interopDefaultLegacy(Data);
var EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
var Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator);
- var SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine);
var BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent);
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.1.1): util/index.js
+ * Bootstrap (v5.0.2): util/index.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
+
const MAX_UID = 1000000;
const toType = obj => {
@@ -87,7 +88,7 @@
}
if (typeof obj === 'string' && obj.length > 0) {
- return document.querySelector(obj);
+ return SelectorEngine__default['default'].findOne(obj);
}
return null;
@@ -182,7 +183,7 @@
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.1.1): util/sanitizer.js
+ * Bootstrap (v5.0.2): util/sanitizer.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
@@ -295,7 +296,7 @@
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.1.1): tooltip.js
+ * Bootstrap (v5.0.2): tooltip.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
@@ -309,6 +310,7 @@
const DATA_KEY = 'bs.tooltip';
const EVENT_KEY = `.${DATA_KEY}`;
const CLASS_PREFIX = 'bs-tooltip';
+ const BSCLS_PREFIX_REGEX = new RegExp(`(^|\\s)${CLASS_PREFIX}\\S+`, 'g');
const DISALLOWED_ATTRIBUTES = new Set(['sanitize', 'allowList', 'sanitizeFn']);
const DefaultType = {
animation: 'boolean',
@@ -373,8 +375,6 @@
const HOVER_STATE_SHOW = 'show';
const HOVER_STATE_OUT = 'out';
const SELECTOR_TOOLTIP_INNER = '.tooltip-inner';
- const SELECTOR_MODAL = `.${CLASS_NAME_MODAL}`;
- const EVENT_MODAL_HIDE = 'hide.bs.modal';
const TRIGGER_HOVER = 'hover';
const TRIGGER_FOCUS = 'focus';
const TRIGGER_CLICK = 'click';
@@ -463,13 +463,15 @@
dispose() {
clearTimeout(this._timeout);
- EventHandler__default['default'].off(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
+ EventHandler__default['default'].off(this._element.closest(`.${CLASS_NAME_MODAL}`), 'hide.bs.modal', this._hideModalHandler);
if (this.tip) {
this.tip.remove();
}
- this._disposePopper();
+ if (this._popper) {
+ this._popper.destroy();
+ }
super.dispose();
}
@@ -489,15 +491,6 @@
if (showEvent.defaultPrevented || !isInTheDom) {
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();
@@ -506,6 +499,8 @@
this._element.setAttribute('aria-describedby', tipId);
+ this.setContent();
+
if (this._config.animation) {
tip.classList.add(CLASS_NAME_FADE);
}
@@ -522,7 +517,7 @@
Data__default['default'].set(tip, this.constructor.DATA_KEY, this);
if (!this._element.ownerDocument.documentElement.contains(this.tip)) {
- container.append(tip);
+ container.appendChild(tip);
EventHandler__default['default'].trigger(this._element, this.constructor.Event.INSERTED);
}
@@ -533,8 +528,7 @@
}
tip.classList.add(CLASS_NAME_SHOW);
-
- const customClass = this._resolvePossibleFunction(this._config.customClass);
+ const customClass = typeof this._config.customClass === 'function' ? this._config.customClass() : this._config.customClass;
if (customClass) {
tip.classList.add(...customClass.split(' '));
@@ -587,7 +581,11 @@
EventHandler__default['default'].trigger(this._element, this.constructor.Event.HIDDEN);
- this._disposePopper();
+ if (this._popper) {
+ this._popper.destroy();
+
+ this._popper = null;
+ }
};
const hideEvent = EventHandler__default['default'].trigger(this._element, this.constructor.Event.HIDE);
@@ -631,27 +629,14 @@
const element = document.createElement('div');
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;
+ this.tip = element.children[0];
return this.tip;
}
- setContent(tip) {
- this._sanitizeAndSetContent(tip, this.getTitle(), SELECTOR_TOOLTIP_INNER);
- }
-
- _sanitizeAndSetContent(template, content, selector) {
- const templateElement = SelectorEngine__default['default'].findOne(selector, template);
-
- if (!content && templateElement) {
- templateElement.remove();
- return;
- } // we use append for html objects to maintain js events
-
-
- this.setElementContent(templateElement, content);
+ setContent() {
+ const tip = this.getTipElement();
+ this.setElementContent(SelectorEngine__default['default'].findOne(SELECTOR_TOOLTIP_INNER, tip), this.getTitle());
+ tip.classList.remove(CLASS_NAME_FADE, CLASS_NAME_SHOW);
}
setElementContent(element, content) {
@@ -665,7 +650,7 @@
if (this._config.html) {
if (content.parentNode !== element) {
element.innerHTML = '';
- element.append(content);
+ element.appendChild(content);
}
} else {
element.textContent = content.textContent;
@@ -686,9 +671,13 @@
}
getTitle() {
- const title = this._element.getAttribute('data-bs-original-title') || this._config.title;
+ let title = this._element.getAttribute('data-bs-original-title');
- return this._resolvePossibleFunction(title);
+ if (!title) {
+ title = typeof this._config.title === 'function' ? this._config.title.call(this._element) : this._config.title;
+ }
+
+ return title;
}
updateAttachment(attachment) {
@@ -705,7 +694,15 @@
_initializeOnDelegatedTarget(event, context) {
- return context || this.constructor.getOrCreateInstance(event.delegateTarget, this._getDelegateConfig());
+ const dataKey = this.constructor.DATA_KEY;
+ context = context || Data__default['default'].get(event.delegateTarget, dataKey);
+
+ if (!context) {
+ context = new this.constructor(event.delegateTarget, this._getDelegateConfig());
+ Data__default['default'].set(event.delegateTarget, dataKey, context);
+ }
+
+ return context;
}
_getOffset() {
@@ -724,10 +721,6 @@
return offset;
}
- _resolvePossibleFunction(content) {
- return typeof content === 'function' ? content.call(this._element) : content;
- }
-
_getPopperConfig(attachment) {
const defaultBsPopperConfig = {
placement: attachment,
@@ -769,7 +762,7 @@
}
_addAttachmentClass(attachment) {
- this.getTipElement().classList.add(`${this._getBasicClassPrefix()}-${this.updateAttachment(attachment)}`);
+ this.getTipElement().classList.add(`${CLASS_PREFIX}-${this.updateAttachment(attachment)}`);
}
_getAttachment(placement) {
@@ -796,7 +789,7 @@
}
};
- EventHandler__default['default'].on(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
+ EventHandler__default['default'].on(this._element.closest(`.${CLASS_NAME_MODAL}`), 'hide.bs.modal', this._hideModalHandler);
if (this._config.selector) {
this._config = { ...this._config,
@@ -927,32 +920,26 @@
_getDelegateConfig() {
const config = {};
- for (const key in this._config) {
- if (this.constructor.Default[key] !== this._config[key]) {
- config[key] = this._config[key];
+ if (this._config) {
+ for (const key in this._config) {
+ if (this.constructor.Default[key] !== this._config[key]) {
+ config[key] = this._config[key];
+ }
}
- } // 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)`
-
+ }
return config;
}
_cleanTipClass() {
const tip = this.getTipElement();
- const basicClassPrefixRegex = new RegExp(`(^|\\s)${this._getBasicClassPrefix()}\\S+`, 'g');
- const tabClass = tip.getAttribute('class').match(basicClassPrefixRegex);
+ const tabClass = tip.getAttribute('class').match(BSCLS_PREFIX_REGEX);
if (tabClass !== null && tabClass.length > 0) {
tabClass.map(token => token.trim()).forEach(tClass => tip.classList.remove(tClass));
}
}
- _getBasicClassPrefix() {
- return CLASS_PREFIX;
- }
-
_handlePopperPlacementChange(popperData) {
const {
state
@@ -967,14 +954,6 @@
this._cleanTipClass();
this._addAttachmentClass(this._getAttachment(state.placement));
- }
-
- _disposePopper() {
- if (this._popper) {
- this._popper.destroy();
-
- this._popper = null;
- }
} // Static