assets/javascripts/bootstrap.js in bootstrap-5.1.0 vs assets/javascripts/bootstrap.js in bootstrap-5.1.1

- old
+ new

@@ -1,7 +1,7 @@ /*! - * Bootstrap v5.1.0 (https://getbootstrap.com/) + * Bootstrap v5.1.1 (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')) : @@ -31,11 +31,11 @@ var Popper__namespace = /*#__PURE__*/_interopNamespace(Popper); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.0): util/index.js + * Bootstrap (v5.1.1): util/index.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ const MAX_UID = 1000000; const MILLISECONDS_MULTIPLIER = 1000; @@ -342,11 +342,11 @@ return list[Math.max(0, Math.min(index, listLength - 1))]; }; /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.0): dom/event-handler.js + * Bootstrap (v5.1.1): dom/event-handler.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** * ------------------------------------------------------------------------ @@ -405,11 +405,10 @@ for (let i = domElements.length; i--;) { if (domElements[i] === target) { event.delegateTarget = target; if (handler.oneOff) { - // eslint-disable-next-line unicorn/consistent-destructuring EventHandler.off(element, event.type, selector, fn); } return fn.apply(target, [event]); } @@ -631,11 +630,11 @@ }; /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.0): dom/data.js + * Bootstrap (v5.1.1): dom/data.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** @@ -685,21 +684,21 @@ }; /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.0): base-component.js + * Bootstrap (v5.1.1): base-component.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** * ------------------------------------------------------------------------ * Constants * ------------------------------------------------------------------------ */ - const VERSION = '5.1.0'; + const VERSION = '5.1.1'; class BaseComponent { constructor(element) { element = getElement(element); @@ -751,11 +750,11 @@ } /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.0): util/component-functions.js + * Bootstrap (v5.1.1): util/component-functions.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ const enableDismissTrigger = (component, method = 'hide') => { @@ -777,11 +776,11 @@ }); }; /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.0): alert.js + * Bootstrap (v5.1.1): alert.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** * ------------------------------------------------------------------------ @@ -866,11 +865,11 @@ defineJQueryPlugin(Alert); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.0): button.js + * Bootstrap (v5.1.1): button.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** * ------------------------------------------------------------------------ @@ -937,11 +936,11 @@ defineJQueryPlugin(Button); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.0): dom/manipulator.js + * Bootstrap (v5.1.1): dom/manipulator.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ function normalizeData(val) { if (val === 'true') { @@ -1011,11 +1010,11 @@ }; /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.0): dom/selector-engine.js + * Bootstrap (v5.1.1): dom/selector-engine.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ const NODE_TEXT = 3; const SelectorEngine = { @@ -1081,11 +1080,11 @@ }; /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.0): carousel.js + * Bootstrap (v5.1.1): carousel.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** * ------------------------------------------------------------------------ @@ -1306,12 +1305,16 @@ this._addTouchEventListeners(); } } _addTouchEventListeners() { + const hasPointerPenTouch = event => { + return this._pointerEvent && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH); + }; + const start = event => { - if (this._pointerEvent && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH)) { + if (hasPointerPenTouch(event)) { this.touchStartX = event.clientX; } else if (!this._pointerEvent) { this.touchStartX = event.touches[0].clientX; } }; @@ -1320,11 +1323,11 @@ // ensure swiping with one touch and not pinching this.touchDeltaX = event.touches && event.touches.length > 1 ? 0 : event.touches[0].clientX - this.touchStartX; }; const end = event => { - if (this._pointerEvent && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH)) { + if (hasPointerPenTouch(event)) { this.touchDeltaX = event.clientX - this.touchStartX; } this._handleSwipe(); @@ -1626,11 +1629,11 @@ defineJQueryPlugin(Carousel); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.0): collapse.js + * Bootstrap (v5.1.1): collapse.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** * ------------------------------------------------------------------------ @@ -1660,11 +1663,11 @@ const CLASS_NAME_COLLAPSING = 'collapsing'; const CLASS_NAME_COLLAPSED = 'collapsed'; const CLASS_NAME_HORIZONTAL = 'collapse-horizontal'; const WIDTH = 'width'; const HEIGHT = 'height'; - const SELECTOR_ACTIVES = '.show, .collapsing'; + const SELECTOR_ACTIVES = '.collapse.show, .collapse.collapsing'; const SELECTOR_DATA_TOGGLE$4 = '[data-bs-toggle="collapse"]'; /** * ------------------------------------------------------------------------ * Class Definition * ------------------------------------------------------------------------ @@ -1944,11 +1947,11 @@ defineJQueryPlugin(Collapse); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.0): dropdown.js + * Bootstrap (v5.1.1): dropdown.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** * ------------------------------------------------------------------------ @@ -2406,11 +2409,11 @@ defineJQueryPlugin(Dropdown); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.0): util/scrollBar.js + * Bootstrap (v5.1.1): util/scrollBar.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top'; const SELECTOR_STICKY_CONTENT = '.sticky-top'; @@ -2510,11 +2513,11 @@ } /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.0): util/backdrop.js + * Bootstrap (v5.1.1): util/backdrop.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ const Default$7 = { className: 'modal-backdrop', @@ -2634,11 +2637,11 @@ } /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.0): util/focustrap.js + * Bootstrap (v5.1.1): util/focustrap.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ const Default$6 = { trapElement: null, @@ -2737,11 +2740,11 @@ } /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.0): modal.js + * Bootstrap (v5.1.1): modal.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** * ------------------------------------------------------------------------ @@ -2777,10 +2780,11 @@ const EVENT_CLICK_DATA_API$2 = `click${EVENT_KEY$6}${DATA_API_KEY$3}`; const CLASS_NAME_OPEN = 'modal-open'; const CLASS_NAME_FADE$3 = 'fade'; const CLASS_NAME_SHOW$4 = 'show'; const CLASS_NAME_STATIC = 'modal-static'; + const OPEN_SELECTOR$1 = '.modal.show'; const SELECTOR_DIALOG = '.modal-dialog'; const SELECTOR_MODAL_BODY = '.modal-body'; const SELECTOR_DATA_TOGGLE$2 = '[data-bs-toggle="modal"]'; /** * ------------------------------------------------------------------------ @@ -3142,11 +3146,18 @@ EventHandler.one(target, EVENT_HIDDEN$3, () => { if (isVisible(this)) { this.focus(); } }); - }); + }); // avoid conflict when clicking moddal toggler while another one is open + + const allReadyOpen = SelectorEngine.findOne(OPEN_SELECTOR$1); + + if (allReadyOpen) { + Modal.getInstance(allReadyOpen).hide(); + } + const data = Modal.getOrCreateInstance(target); data.toggle(this); }); enableDismissTrigger(Modal); /** @@ -3158,11 +3169,11 @@ defineJQueryPlugin(Modal); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.0): offcanvas.js + * Bootstrap (v5.1.1): offcanvas.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ /** * ------------------------------------------------------------------------ @@ -3414,11 +3425,11 @@ defineJQueryPlugin(Offcanvas); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.0): util/sanitizer.js + * Bootstrap (v5.1.1): util/sanitizer.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ const uriAttrs = new Set(['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href']); const ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i; @@ -3527,11 +3538,11 @@ return createdDocument.body.innerHTML; } /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.0): tooltip.js + * Bootstrap (v5.1.1): tooltip.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** * ------------------------------------------------------------------------ @@ -3701,13 +3712,11 @@ if (this.tip) { this.tip.remove(); } - if (this._popper) { - this._popper.destroy(); - } + this._disposePopper(); super.dispose(); } show() { @@ -3723,10 +3732,19 @@ const shadowRoot = findShadowRoot(this._element); const isInTheDom = shadowRoot === null ? this._element.ownerDocument.documentElement.contains(this._element) : shadowRoot.contains(this._element); 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(); const tipId = getUID(this.constructor.NAME); tip.setAttribute('id', tipId); @@ -3812,15 +3830,11 @@ 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); if (hideEvent.defaultPrevented) { @@ -4196,10 +4210,18 @@ this.tip = state.elements.popper; this._cleanTipClass(); this._addAttachmentClass(this._getAttachment(state.placement)); + } + + _disposePopper() { + if (this._popper) { + this._popper.destroy(); + + this._popper = null; + } } // Static static jQueryInterface(config) { return this.each(function () { @@ -4226,11 +4248,11 @@ defineJQueryPlugin(Tooltip); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.0): popover.js + * Bootstrap (v5.1.1): popover.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** * ------------------------------------------------------------------------ @@ -4336,11 +4358,11 @@ defineJQueryPlugin(Popover); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.0): scrollspy.js + * Bootstrap (v5.1.1): scrollspy.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** * ------------------------------------------------------------------------ @@ -4571,11 +4593,11 @@ defineJQueryPlugin(ScrollSpy); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.0): tab.js + * Bootstrap (v5.1.1): tab.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** * ------------------------------------------------------------------------ @@ -4769,11 +4791,11 @@ defineJQueryPlugin(Tab); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.0): toast.js + * Bootstrap (v5.1.1): toast.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** * ------------------------------------------------------------------------ @@ -4999,10 +5021,10 @@ defineJQueryPlugin(Toast); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.0): index.umd.js + * Bootstrap (v5.1.1): index.umd.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ var index_umd = { Alert,