assets/javascripts/bootstrap.js in bootstrap-5.0.0.beta1 vs assets/javascripts/bootstrap.js in bootstrap-5.0.0.beta2
- old
+ new
@@ -1,8 +1,8 @@
/*!
- * Bootstrap v5.0.0-beta1 (https://getbootstrap.com/)
- * Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
+ * Bootstrap v5.0.0-beta2 (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')) :
typeof define === 'function' && define.amd ? define(['@popperjs/core'], factory) :
@@ -66,16 +66,26 @@
}
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
- subClass.__proto__ = superClass;
+
+ _setPrototypeOf(subClass, superClass);
}
+ function _setPrototypeOf(o, p) {
+ _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
+ o.__proto__ = p;
+ return o;
+ };
+
+ return _setPrototypeOf(o, p);
+ }
+
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.0-beta1): util/index.js
+ * Bootstrap (v5.0.0-beta2): util/index.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
var MAX_UID = 1000000;
var MILLISECONDS_MULTIPLIER = 1000;
@@ -105,11 +115,24 @@
var getSelector = function getSelector(element) {
var selector = element.getAttribute('data-bs-target');
if (!selector || selector === '#') {
- var hrefAttr = element.getAttribute('href');
+ var hrefAttr = element.getAttribute('href'); // The only valid content that could double as a selector are IDs or classes,
+ // so everything starting with `#` or `.`. If a "real" URL is used as the selector,
+ // `document.querySelector` will rightfully complain it is invalid.
+ // See https://github.com/twbs/bootstrap/issues/32273
+
+ if (!hrefAttr || !hrefAttr.includes('#') && !hrefAttr.startsWith('.')) {
+ return null;
+ } // Just in case some CMS puts out a full URL with the anchor appended
+
+
+ if (hrefAttr.includes('#') && !hrefAttr.startsWith('#')) {
+ hrefAttr = '#' + hrefAttr.split('#')[1];
+ }
+
selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null;
}
return selector;
};
@@ -183,11 +206,11 @@
var expectedTypes = configTypes[property];
var value = config[property];
var valueType = value && isElement(value) ? 'element' : toType(value);
if (!new RegExp(expectedTypes).test(valueType)) {
- throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\"."));
+ throw new TypeError(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\"."));
}
});
};
var isVisible = function isVisible(element) {
@@ -254,13 +277,31 @@
}
};
var isRTL = document.documentElement.dir === 'rtl';
+ var defineJQueryPlugin = function defineJQueryPlugin(name, plugin) {
+ onDOMContentLoaded(function () {
+ var $ = getjQuery();
+ /* istanbul ignore if */
+
+ if ($) {
+ var JQUERY_NO_CONFLICT = $.fn[name];
+ $.fn[name] = plugin.jQueryInterface;
+ $.fn[name].Constructor = plugin;
+
+ $.fn[name].noConflict = function () {
+ $.fn[name] = JQUERY_NO_CONFLICT;
+ return plugin.jQueryInterface;
+ };
+ }
+ });
+ };
+
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.0-beta1): dom/data.js
+ * Bootstrap (v5.0.0-beta2): dom/data.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
@@ -323,11 +364,11 @@
}
};
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.0-beta1): dom/event-handler.js
+ * Bootstrap (v5.0.0-beta2): dom/event-handler.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* ------------------------------------------------------------------------
@@ -383,10 +424,11 @@
for (var 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, fn);
}
return fn.apply(target, [event]);
}
@@ -602,11 +644,11 @@
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
- var VERSION = '5.0.0-beta1';
+ var VERSION = '5.0.0-beta2';
var BaseComponent = /*#__PURE__*/function () {
function BaseComponent(element) {
if (!element) {
return;
@@ -651,13 +693,13 @@
var DATA_API_KEY = '.data-api';
var SELECTOR_DISMISS = '[data-bs-dismiss="alert"]';
var EVENT_CLOSE = "close" + EVENT_KEY;
var EVENT_CLOSED = "closed" + EVENT_KEY;
var EVENT_CLICK_DATA_API = "click" + EVENT_KEY + DATA_API_KEY;
- var CLASSNAME_ALERT = 'alert';
- var CLASSNAME_FADE = 'fade';
- var CLASSNAME_SHOW = 'show';
+ var CLASS_NAME_ALERT = 'alert';
+ var CLASS_NAME_FADE = 'fade';
+ var CLASS_NAME_SHOW = 'show';
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
@@ -684,30 +726,30 @@
this._removeElement(rootElement);
} // Private
;
_proto._getRootElement = function _getRootElement(element) {
- return getElementFromSelector(element) || element.closest("." + CLASSNAME_ALERT);
+ return getElementFromSelector(element) || element.closest("." + CLASS_NAME_ALERT);
};
_proto._triggerCloseEvent = function _triggerCloseEvent(element) {
return EventHandler.trigger(element, EVENT_CLOSE);
};
_proto._removeElement = function _removeElement(element) {
var _this = this;
- element.classList.remove(CLASSNAME_SHOW);
+ element.classList.remove(CLASS_NAME_SHOW);
- if (!element.classList.contains(CLASSNAME_FADE)) {
+ if (!element.classList.contains(CLASS_NAME_FADE)) {
this._destroyElement(element);
return;
}
var transitionDuration = getTransitionDurationFromElement(element);
- EventHandler.one(element, TRANSITION_END, function () {
+ EventHandler.one(element, 'transitionend', function () {
return _this._destroyElement(element);
});
emulateTransitionEnd(element, transitionDuration);
};
@@ -744,12 +786,12 @@
};
};
_createClass(Alert, null, [{
key: "DATA_KEY",
- // Getters
- get: function get() {
+ get: // Getters
+ function get() {
return DATA_KEY;
}
}]);
return Alert;
@@ -767,26 +809,12 @@
* jQuery
* ------------------------------------------------------------------------
* add .Alert to jQuery only if jQuery is present
*/
- onDOMContentLoaded(function () {
- var $ = getjQuery();
- /* istanbul ignore if */
+ defineJQueryPlugin(NAME, Alert);
- if ($) {
- var JQUERY_NO_CONFLICT = $.fn[NAME];
- $.fn[NAME] = Alert.jQueryInterface;
- $.fn[NAME].Constructor = Alert;
-
- $.fn[NAME].noConflict = function () {
- $.fn[NAME] = JQUERY_NO_CONFLICT;
- return Alert.jQueryInterface;
- };
- }
- });
-
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
@@ -834,12 +862,12 @@
});
};
_createClass(Button, null, [{
key: "DATA_KEY",
- // Getters
- get: function get() {
+ get: // Getters
+ function get() {
return DATA_KEY$1;
}
}]);
return Button;
@@ -867,29 +895,15 @@
* jQuery
* ------------------------------------------------------------------------
* add .Button to jQuery only if jQuery is present
*/
- onDOMContentLoaded(function () {
- var $ = getjQuery();
- /* istanbul ignore if */
+ defineJQueryPlugin(NAME$1, Button);
- if ($) {
- var JQUERY_NO_CONFLICT = $.fn[NAME$1];
- $.fn[NAME$1] = Button.jQueryInterface;
- $.fn[NAME$1].Constructor = Button;
-
- $.fn[NAME$1].noConflict = function () {
- $.fn[NAME$1] = JQUERY_NO_CONFLICT;
- return Button.jQueryInterface;
- };
- }
- });
-
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.0-beta1): dom/manipulator.js
+ * Bootstrap (v5.0.0-beta2): dom/manipulator.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
function normalizeData(val) {
if (val === 'true') {
@@ -957,11 +971,11 @@
}
};
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.0-beta1): dom/selector-engine.js
+ * Bootstrap (v5.0.0-beta2): dom/selector-engine.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
@@ -969,13 +983,10 @@
* Constants
* ------------------------------------------------------------------------
*/
var NODE_TEXT = 3;
var SelectorEngine = {
- matches: function matches(element, selector) {
- return element.matches(selector);
- },
find: function find(selector, element) {
var _ref;
if (element === void 0) {
element = document.documentElement;
@@ -991,22 +1002,20 @@
return Element.prototype.querySelector.call(element, selector);
},
children: function children(element, selector) {
var _ref2;
- var children = (_ref2 = []).concat.apply(_ref2, element.children);
-
- return children.filter(function (child) {
+ return (_ref2 = []).concat.apply(_ref2, element.children).filter(function (child) {
return child.matches(selector);
});
},
parents: function parents(element, selector) {
var parents = [];
var ancestor = element.parentNode;
while (ancestor && ancestor.nodeType === Node.ELEMENT_NODE && ancestor.nodeType !== NODE_TEXT) {
- if (this.matches(ancestor, selector)) {
+ if (ancestor.matches(selector)) {
parents.push(ancestor);
}
ancestor = ancestor.parentNode;
}
@@ -1028,11 +1037,11 @@
},
next: function next(element, selector) {
var next = element.nextElementSibling;
while (next) {
- if (this.matches(next, selector)) {
+ if (next.matches(selector)) {
return [next];
}
next = next.nextElementSibling;
}
@@ -1101,16 +1110,15 @@
var SELECTOR_ACTIVE_ITEM = '.active.carousel-item';
var SELECTOR_ITEM = '.carousel-item';
var SELECTOR_ITEM_IMG = '.carousel-item img';
var SELECTOR_NEXT_PREV = '.carousel-item-next, .carousel-item-prev';
var SELECTOR_INDICATORS = '.carousel-indicators';
+ var SELECTOR_INDICATOR = '[data-bs-target]';
var SELECTOR_DATA_SLIDE = '[data-bs-slide], [data-bs-slide-to]';
var SELECTOR_DATA_RIDE = '[data-bs-ride="carousel"]';
- var PointerType = {
- TOUCH: 'touch',
- PEN: 'pen'
- };
+ var POINTER_TYPE_TOUCH = 'touch';
+ var POINTER_TYPE_PEN = 'pen';
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
@@ -1253,16 +1261,24 @@
var direction = absDeltax / this.touchDeltaX;
this.touchDeltaX = 0; // swipe left
if (direction > 0) {
- this.prev();
+ if (isRTL) {
+ this.next();
+ } else {
+ this.prev();
+ }
} // swipe right
if (direction < 0) {
- this.next();
+ if (isRTL) {
+ this.prev();
+ } else {
+ this.next();
+ }
}
};
_proto._addEventListeners = function _addEventListeners() {
var _this3 = this;
@@ -1289,11 +1305,11 @@
_proto._addTouchEventListeners = function _addTouchEventListeners() {
var _this4 = this;
var start = function start(event) {
- if (_this4._pointerEvent && PointerType[event.pointerType.toUpperCase()]) {
+ if (_this4._pointerEvent && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH)) {
_this4.touchStartX = event.clientX;
} else if (!_this4._pointerEvent) {
_this4.touchStartX = event.touches[0].clientX;
}
};
@@ -1306,11 +1322,11 @@
_this4.touchDeltaX = event.touches[0].clientX - _this4.touchStartX;
}
};
var end = function end(event) {
- if (_this4._pointerEvent && PointerType[event.pointerType.toUpperCase()]) {
+ if (_this4._pointerEvent && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH)) {
_this4.touchDeltaX = event.clientX - _this4.touchStartX;
}
_this4._handleSwipe();
@@ -1365,20 +1381,26 @@
_proto._keydown = function _keydown(event) {
if (/input|textarea/i.test(event.target.tagName)) {
return;
}
- switch (event.key) {
- case ARROW_LEFT_KEY:
- event.preventDefault();
+ if (event.key === ARROW_LEFT_KEY) {
+ event.preventDefault();
+
+ if (isRTL) {
+ this.next();
+ } else {
this.prev();
- break;
+ }
+ } else if (event.key === ARROW_RIGHT_KEY) {
+ event.preventDefault();
- case ARROW_RIGHT_KEY:
- event.preventDefault();
+ if (isRTL) {
+ this.prev();
+ } else {
this.next();
- break;
+ }
}
};
_proto._getItemIndex = function _getItemIndex(element) {
this._items = element && element.parentNode ? SelectorEngine.find(SELECTOR_ITEM, element.parentNode) : [];
@@ -1416,21 +1438,22 @@
});
};
_proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
if (this._indicatorsElement) {
- var indicators = SelectorEngine.find(SELECTOR_ACTIVE, this._indicatorsElement);
+ var activeIndicator = SelectorEngine.findOne(SELECTOR_ACTIVE, this._indicatorsElement);
+ activeIndicator.classList.remove(CLASS_NAME_ACTIVE$1);
+ activeIndicator.removeAttribute('aria-current');
+ var indicators = SelectorEngine.find(SELECTOR_INDICATOR, this._indicatorsElement);
for (var i = 0; i < indicators.length; i++) {
- indicators[i].classList.remove(CLASS_NAME_ACTIVE$1);
+ if (Number.parseInt(indicators[i].getAttribute('data-bs-slide-to'), 10) === this._getItemIndex(element)) {
+ indicators[i].classList.add(CLASS_NAME_ACTIVE$1);
+ indicators[i].setAttribute('aria-current', 'true');
+ break;
+ }
}
-
- var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
-
- if (nextIndicator) {
- nextIndicator.classList.add(CLASS_NAME_ACTIVE$1);
- }
}
};
_proto._updateInterval = function _updateInterval() {
var element = this._activeElement || SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element);
@@ -1459,24 +1482,14 @@
var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
var nextElementIndex = this._getItemIndex(nextElement);
var isCycling = Boolean(this._interval);
- var directionalClassName;
- var orderClassName;
- var eventDirectionName;
+ var directionalClassName = direction === DIRECTION_NEXT ? CLASS_NAME_START : CLASS_NAME_END;
+ var orderClassName = direction === DIRECTION_NEXT ? CLASS_NAME_NEXT : CLASS_NAME_PREV;
+ var eventDirectionName = direction === DIRECTION_NEXT ? DIRECTION_LEFT : DIRECTION_RIGHT;
- if (direction === DIRECTION_NEXT) {
- directionalClassName = CLASS_NAME_START;
- orderClassName = CLASS_NAME_NEXT;
- eventDirectionName = DIRECTION_LEFT;
- } else {
- directionalClassName = CLASS_NAME_END;
- orderClassName = CLASS_NAME_PREV;
- eventDirectionName = DIRECTION_RIGHT;
- }
-
if (nextElement && nextElement.classList.contains(CLASS_NAME_ACTIVE$1)) {
this._isSliding = false;
return;
}
@@ -1505,11 +1518,11 @@
nextElement.classList.add(orderClassName);
reflow(nextElement);
activeElement.classList.add(directionalClassName);
nextElement.classList.add(directionalClassName);
var transitionDuration = getTransitionDurationFromElement(activeElement);
- EventHandler.one(activeElement, TRANSITION_END, function () {
+ EventHandler.one(activeElement, 'transitionend', function () {
nextElement.classList.remove(directionalClassName, orderClassName);
nextElement.classList.add(CLASS_NAME_ACTIVE$1);
activeElement.classList.remove(CLASS_NAME_ACTIVE$1, orderClassName, directionalClassName);
_this5._isSliding = false;
setTimeout(function () {
@@ -1633,26 +1646,12 @@
* jQuery
* ------------------------------------------------------------------------
* add .Carousel to jQuery only if jQuery is present
*/
- onDOMContentLoaded(function () {
- var $ = getjQuery();
- /* istanbul ignore if */
+ defineJQueryPlugin(NAME$2, Carousel);
- if ($) {
- var JQUERY_NO_CONFLICT = $.fn[NAME$2];
- $.fn[NAME$2] = Carousel.jQueryInterface;
- $.fn[NAME$2].Constructor = Carousel;
-
- $.fn[NAME$2].noConflict = function () {
- $.fn[NAME$2] = JQUERY_NO_CONFLICT;
- return Carousel.jQueryInterface;
- };
- }
- });
-
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
@@ -1672,11 +1671,11 @@
var EVENT_SHOW = "show" + EVENT_KEY$3;
var EVENT_SHOWN = "shown" + EVENT_KEY$3;
var EVENT_HIDE = "hide" + EVENT_KEY$3;
var EVENT_HIDDEN = "hidden" + EVENT_KEY$3;
var EVENT_CLICK_DATA_API$3 = "click" + EVENT_KEY$3 + DATA_API_KEY$3;
- var CLASS_NAME_SHOW = 'show';
+ var CLASS_NAME_SHOW$1 = 'show';
var CLASS_NAME_COLLAPSE = 'collapse';
var CLASS_NAME_COLLAPSING = 'collapsing';
var CLASS_NAME_COLLAPSED = 'collapsed';
var WIDTH = 'width';
var HEIGHT = 'height';
@@ -1730,21 +1729,21 @@
var _proto = Collapse.prototype;
// Public
_proto.toggle = function toggle() {
- if (this._element.classList.contains(CLASS_NAME_SHOW)) {
+ if (this._element.classList.contains(CLASS_NAME_SHOW$1)) {
this.hide();
} else {
this.show();
}
};
_proto.show = function show() {
var _this2 = this;
- if (this._isTransitioning || this._element.classList.contains(CLASS_NAME_SHOW)) {
+ if (this._isTransitioning || this._element.classList.contains(CLASS_NAME_SHOW$1)) {
return;
}
var actives;
var activesData;
@@ -1812,11 +1811,11 @@
this.setTransitioning(true);
var complete = function complete() {
_this2._element.classList.remove(CLASS_NAME_COLLAPSING);
- _this2._element.classList.add(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW);
+ _this2._element.classList.add(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$1);
_this2._element.style[dimension] = '';
_this2.setTransitioning(false);
@@ -1824,19 +1823,19 @@
};
var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
var scrollSize = "scroll" + capitalizedDimension;
var transitionDuration = getTransitionDurationFromElement(this._element);
- EventHandler.one(this._element, TRANSITION_END, complete);
+ EventHandler.one(this._element, 'transitionend', complete);
emulateTransitionEnd(this._element, transitionDuration);
this._element.style[dimension] = this._element[scrollSize] + "px";
};
_proto.hide = function hide() {
var _this3 = this;
- if (this._isTransitioning || !this._element.classList.contains(CLASS_NAME_SHOW)) {
+ if (this._isTransitioning || !this._element.classList.contains(CLASS_NAME_SHOW$1)) {
return;
}
var startEvent = EventHandler.trigger(this._element, EVENT_HIDE);
@@ -1849,20 +1848,20 @@
this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px";
reflow(this._element);
this._element.classList.add(CLASS_NAME_COLLAPSING);
- this._element.classList.remove(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW);
+ this._element.classList.remove(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$1);
var triggerArrayLength = this._triggerArray.length;
if (triggerArrayLength > 0) {
for (var i = 0; i < triggerArrayLength; i++) {
var trigger = this._triggerArray[i];
var elem = getElementFromSelector(trigger);
- if (elem && !elem.classList.contains(CLASS_NAME_SHOW)) {
+ if (elem && !elem.classList.contains(CLASS_NAME_SHOW$1)) {
trigger.classList.add(CLASS_NAME_COLLAPSED);
trigger.setAttribute('aria-expanded', false);
}
}
}
@@ -1879,11 +1878,11 @@
EventHandler.trigger(_this3._element, EVENT_HIDDEN);
};
this._element.style[dimension] = '';
var transitionDuration = getTransitionDurationFromElement(this._element);
- EventHandler.one(this._element, TRANSITION_END, complete);
+ EventHandler.one(this._element, 'transitionend', complete);
emulateTransitionEnd(this._element, transitionDuration);
};
_proto.setTransitioning = function setTransitioning(isTransitioning) {
this._isTransitioning = isTransitioning;
@@ -1937,11 +1936,11 @@
_proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
if (!element || !triggerArray.length) {
return;
}
- var isOpen = element.classList.contains(CLASS_NAME_SHOW);
+ var isOpen = element.classList.contains(CLASS_NAME_SHOW$1);
triggerArray.forEach(function (elem) {
if (isOpen) {
elem.classList.remove(CLASS_NAME_COLLAPSED);
} else {
elem.classList.add(CLASS_NAME_COLLAPSED);
@@ -2001,11 +2000,11 @@
*/
EventHandler.on(document, EVENT_CLICK_DATA_API$3, SELECTOR_DATA_TOGGLE$1, function (event) {
// preventDefault only for <a> elements (which change the URL) not inside the collapsible element
- if (event.target.tagName === 'A') {
+ if (event.target.tagName === 'A' || event.delegateTarget && event.delegateTarget.tagName === 'A') {
event.preventDefault();
}
var triggerData = Manipulator.getDataAttributes(this);
var selector = getSelectorFromElement(this);
@@ -2034,26 +2033,12 @@
* jQuery
* ------------------------------------------------------------------------
* add .Collapse to jQuery only if jQuery is present
*/
- onDOMContentLoaded(function () {
- var $ = getjQuery();
- /* istanbul ignore if */
+ defineJQueryPlugin(NAME$3, Collapse);
- if ($) {
- var JQUERY_NO_CONFLICT = $.fn[NAME$3];
- $.fn[NAME$3] = Collapse.jQueryInterface;
- $.fn[NAME$3].Constructor = Collapse;
-
- $.fn[NAME$3].noConflict = function () {
- $.fn[NAME$3] = JQUERY_NO_CONFLICT;
- return Collapse.jQueryInterface;
- };
- }
- });
-
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
@@ -2077,11 +2062,11 @@
var EVENT_CLICK = "click" + EVENT_KEY$4;
var EVENT_CLICK_DATA_API$4 = "click" + EVENT_KEY$4 + DATA_API_KEY$4;
var EVENT_KEYDOWN_DATA_API = "keydown" + EVENT_KEY$4 + DATA_API_KEY$4;
var EVENT_KEYUP_DATA_API = "keyup" + EVENT_KEY$4 + DATA_API_KEY$4;
var CLASS_NAME_DISABLED = 'disabled';
- var CLASS_NAME_SHOW$1 = 'show';
+ var CLASS_NAME_SHOW$2 = 'show';
var CLASS_NAME_DROPUP = 'dropup';
var CLASS_NAME_DROPEND = 'dropend';
var CLASS_NAME_DROPSTART = 'dropstart';
var CLASS_NAME_NAVBAR = 'navbar';
var SELECTOR_DATA_TOGGLE$2 = '[data-bs-toggle="dropdown"]';
@@ -2094,24 +2079,24 @@
var PLACEMENT_BOTTOM = isRTL ? 'bottom-end' : 'bottom-start';
var PLACEMENT_BOTTOMEND = isRTL ? 'bottom-start' : 'bottom-end';
var PLACEMENT_RIGHT = isRTL ? 'left-start' : 'right-start';
var PLACEMENT_LEFT = isRTL ? 'right-start' : 'left-start';
var Default$2 = {
- offset: 0,
+ offset: [0, 2],
flip: true,
boundary: 'clippingParents',
reference: 'toggle',
display: 'dynamic',
popperConfig: null
};
var DefaultType$2 = {
- offset: '(number|string|function)',
+ offset: '(array|string|function)',
flip: 'boolean',
boundary: '(string|element)',
- reference: '(string|element)',
+ reference: '(string|element|object)',
display: 'string',
- popperConfig: '(null|object)'
+ popperConfig: '(null|object|function)'
};
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
@@ -2141,11 +2126,11 @@
_proto.toggle = function toggle() {
if (this._element.disabled || this._element.classList.contains(CLASS_NAME_DISABLED)) {
return;
}
- var isActive = this._element.classList.contains(CLASS_NAME_SHOW$1);
+ var isActive = this._element.classList.contains(CLASS_NAME_SHOW$2);
Dropdown.clearMenus();
if (isActive) {
return;
@@ -2153,11 +2138,11 @@
this.show();
};
_proto.show = function show() {
- if (this._element.disabled || this._element.classList.contains(CLASS_NAME_DISABLED) || this._menu.classList.contains(CLASS_NAME_SHOW$1)) {
+ if (this._element.disabled || this._element.classList.contains(CLASS_NAME_DISABLED) || this._menu.classList.contains(CLASS_NAME_SHOW$2)) {
return;
}
var parent = Dropdown.getParentFromElement(this._element);
var relatedTarget = {
@@ -2168,11 +2153,13 @@
if (showEvent.defaultPrevented) {
return;
} // Totally disable Popper for Dropdowns in Navbar
- if (!this._inNavbar) {
+ if (this._inNavbar) {
+ Manipulator.setDataAttribute(this._menu, 'popper', 'none');
+ } else {
if (typeof Popper__namespace === 'undefined') {
throw new TypeError('Bootstrap\'s dropdowns require Popper (https://popper.js.org)');
}
var referenceElement = this._element;
@@ -2183,13 +2170,24 @@
referenceElement = this._config.reference; // Check if it's jQuery element
if (typeof this._config.reference.jquery !== 'undefined') {
referenceElement = this._config.reference[0];
}
+ } else if (typeof this._config.reference === 'object') {
+ referenceElement = this._config.reference;
}
- this._popper = Popper.createPopper(referenceElement, this._menu, this._getPopperConfig());
+ var popperConfig = this._getPopperConfig();
+
+ var isDisplayStatic = popperConfig.modifiers.find(function (modifier) {
+ return modifier.name === 'applyStyles' && modifier.enabled === false;
+ });
+ this._popper = Popper.createPopper(referenceElement, this._menu, popperConfig);
+
+ if (isDisplayStatic) {
+ Manipulator.setDataAttribute(this._menu, 'popper', 'static');
+ }
} // If this is a touch-enabled device we add extra
// empty mouseover listeners to the body's immediate children;
// only needed because of broken event delegation on iOS
// https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
@@ -2204,41 +2202,41 @@
this._element.focus();
this._element.setAttribute('aria-expanded', true);
- this._menu.classList.toggle(CLASS_NAME_SHOW$1);
+ this._menu.classList.toggle(CLASS_NAME_SHOW$2);
- this._element.classList.toggle(CLASS_NAME_SHOW$1);
+ this._element.classList.toggle(CLASS_NAME_SHOW$2);
- EventHandler.trigger(parent, EVENT_SHOWN$1, relatedTarget);
+ EventHandler.trigger(this._element, EVENT_SHOWN$1, relatedTarget);
};
_proto.hide = function hide() {
- if (this._element.disabled || this._element.classList.contains(CLASS_NAME_DISABLED) || !this._menu.classList.contains(CLASS_NAME_SHOW$1)) {
+ if (this._element.disabled || this._element.classList.contains(CLASS_NAME_DISABLED) || !this._menu.classList.contains(CLASS_NAME_SHOW$2)) {
return;
}
- var parent = Dropdown.getParentFromElement(this._element);
var relatedTarget = {
relatedTarget: this._element
};
- var hideEvent = EventHandler.trigger(parent, EVENT_HIDE$1, relatedTarget);
+ var hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$1, relatedTarget);
if (hideEvent.defaultPrevented) {
return;
}
if (this._popper) {
this._popper.destroy();
}
- this._menu.classList.toggle(CLASS_NAME_SHOW$1);
+ this._menu.classList.toggle(CLASS_NAME_SHOW$2);
- this._element.classList.toggle(CLASS_NAME_SHOW$1);
+ this._element.classList.toggle(CLASS_NAME_SHOW$2);
- EventHandler.trigger(parent, EVENT_HIDDEN$1, relatedTarget);
+ Manipulator.removeDataAttribute(this._menu, 'popper');
+ EventHandler.trigger(this._element, EVENT_HIDDEN$1, relatedTarget);
};
_proto.dispose = function dispose() {
_BaseComponent.prototype.dispose.call(this);
@@ -2273,10 +2271,16 @@
};
_proto._getConfig = function _getConfig(config) {
config = _extends({}, this.constructor.Default, Manipulator.getDataAttributes(this._element), config);
typeCheckConfig(NAME$4, config, this.constructor.DefaultType);
+
+ if (typeof config.reference === 'object' && !isElement(config.reference) && typeof config.reference.getBoundingClientRect !== 'function') {
+ // Popper virtual elements require a getBoundingClientRect method
+ throw new TypeError(NAME$4.toUpperCase() + ": Option \"reference\" provided type \"object\" without a required \"getBoundingClientRect\" method.");
+ }
+
return config;
};
_proto._getMenuElement = function _getMenuElement() {
return SelectorEngine.next(this._element, SELECTOR_MENU)[0];
@@ -2305,30 +2309,55 @@
_proto._detectNavbar = function _detectNavbar() {
return this._element.closest("." + CLASS_NAME_NAVBAR) !== null;
};
+ _proto._getOffset = function _getOffset() {
+ var _this3 = this;
+
+ var offset = this._config.offset;
+
+ if (typeof offset === 'string') {
+ return offset.split(',').map(function (val) {
+ return Number.parseInt(val, 10);
+ });
+ }
+
+ if (typeof offset === 'function') {
+ return function (popperData) {
+ return offset(popperData, _this3._element);
+ };
+ }
+
+ return offset;
+ };
+
_proto._getPopperConfig = function _getPopperConfig() {
- var popperConfig = {
+ var defaultBsPopperConfig = {
placement: this._getPlacement(),
modifiers: [{
name: 'preventOverflow',
options: {
altBoundary: this._config.flip,
- rootBoundary: this._config.boundary
+ boundary: this._config.boundary
}
+ }, {
+ name: 'offset',
+ options: {
+ offset: this._getOffset()
+ }
}]
}; // Disable Popper if we have a static display
if (this._config.display === 'static') {
- popperConfig.modifiers = [{
+ defaultBsPopperConfig.modifiers = [{
name: 'applyStyles',
enabled: false
}];
}
- return _extends({}, popperConfig, this._config.popperConfig);
+ return _extends({}, defaultBsPopperConfig, typeof this._config.popperConfig === 'function' ? this._config.popperConfig(defaultBsPopperConfig) : this._config.popperConfig);
} // Static
;
Dropdown.dropdownInterface = function dropdownInterface(element, config) {
var data = Data.getData(element, DATA_KEY$4);
@@ -2360,11 +2389,10 @@
}
var toggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE$2);
for (var i = 0, len = toggles.length; i < len; i++) {
- var parent = Dropdown.getParentFromElement(toggles[i]);
var context = Data.getData(toggles[i], DATA_KEY$4);
var relatedTarget = {
relatedTarget: toggles[i]
};
@@ -2376,19 +2404,19 @@
continue;
}
var dropdownMenu = context._menu;
- if (!toggles[i].classList.contains(CLASS_NAME_SHOW$1)) {
+ if (!toggles[i].classList.contains(CLASS_NAME_SHOW$2)) {
continue;
}
if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.key === TAB_KEY) && dropdownMenu.contains(event.target)) {
continue;
}
- var hideEvent = EventHandler.trigger(parent, EVENT_HIDE$1, relatedTarget);
+ var hideEvent = EventHandler.trigger(toggles[i], EVENT_HIDE$1, relatedTarget);
if (hideEvent.defaultPrevented) {
continue;
} // If this is a touch-enabled device we remove the extra
// empty mouseover listeners we added for iOS support
@@ -2406,13 +2434,14 @@
if (context._popper) {
context._popper.destroy();
}
- dropdownMenu.classList.remove(CLASS_NAME_SHOW$1);
- toggles[i].classList.remove(CLASS_NAME_SHOW$1);
- EventHandler.trigger(parent, EVENT_HIDDEN$1, relatedTarget);
+ dropdownMenu.classList.remove(CLASS_NAME_SHOW$2);
+ toggles[i].classList.remove(CLASS_NAME_SHOW$2);
+ Manipulator.removeDataAttribute(dropdownMenu, 'popper');
+ EventHandler.trigger(toggles[i], EVENT_HIDDEN$1, relatedTarget);
}
};
Dropdown.getParentFromElement = function getParentFromElement(element) {
return getElementFromSelector(element) || element.parentNode;
@@ -2436,19 +2465,27 @@
if (this.disabled || this.classList.contains(CLASS_NAME_DISABLED)) {
return;
}
var parent = Dropdown.getParentFromElement(this);
- var isActive = this.classList.contains(CLASS_NAME_SHOW$1);
+ var isActive = this.classList.contains(CLASS_NAME_SHOW$2);
if (event.key === ESCAPE_KEY) {
var button = this.matches(SELECTOR_DATA_TOGGLE$2) ? this : SelectorEngine.prev(this, SELECTOR_DATA_TOGGLE$2)[0];
button.focus();
Dropdown.clearMenus();
return;
}
+ if (!isActive && (event.key === ARROW_UP_KEY || event.key === ARROW_DOWN_KEY)) {
+ var _button = this.matches(SELECTOR_DATA_TOGGLE$2) ? this : SelectorEngine.prev(this, SELECTOR_DATA_TOGGLE$2)[0];
+
+ _button.click();
+
+ return;
+ }
+
if (!isActive || event.key === SPACE_KEY) {
Dropdown.clearMenus();
return;
}
@@ -2517,26 +2554,12 @@
* jQuery
* ------------------------------------------------------------------------
* add .Dropdown to jQuery only if jQuery is present
*/
- onDOMContentLoaded(function () {
- var $ = getjQuery();
- /* istanbul ignore if */
+ defineJQueryPlugin(NAME$4, Dropdown);
- if ($) {
- var JQUERY_NO_CONFLICT = $.fn[NAME$4];
- $.fn[NAME$4] = Dropdown.jQueryInterface;
- $.fn[NAME$4].Constructor = Dropdown;
-
- $.fn[NAME$4].noConflict = function () {
- $.fn[NAME$4] = JQUERY_NO_CONFLICT;
- return Dropdown.jQueryInterface;
- };
- }
- });
-
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
@@ -2569,12 +2592,12 @@
var EVENT_MOUSEDOWN_DISMISS = "mousedown.dismiss" + EVENT_KEY$5;
var EVENT_CLICK_DATA_API$5 = "click" + EVENT_KEY$5 + DATA_API_KEY$5;
var CLASS_NAME_SCROLLBAR_MEASURER = 'modal-scrollbar-measure';
var CLASS_NAME_BACKDROP = 'modal-backdrop';
var CLASS_NAME_OPEN = 'modal-open';
- var CLASS_NAME_FADE = 'fade';
- var CLASS_NAME_SHOW$2 = 'show';
+ var CLASS_NAME_FADE$1 = 'fade';
+ var CLASS_NAME_SHOW$3 = 'show';
var CLASS_NAME_STATIC = 'modal-static';
var SELECTOR_DIALOG = '.modal-dialog';
var SELECTOR_MODAL_BODY = '.modal-body';
var SELECTOR_DATA_TOGGLE$3 = '[data-bs-toggle="modal"]';
var SELECTOR_DATA_DISMISS = '[data-bs-dismiss="modal"]';
@@ -2617,11 +2640,11 @@
if (this._isShown || this._isTransitioning) {
return;
}
- if (this._element.classList.contains(CLASS_NAME_FADE)) {
+ if (this._element.classList.contains(CLASS_NAME_FADE$1)) {
this._isTransitioning = true;
}
var showEvent = EventHandler.trigger(this._element, EVENT_SHOW$2, {
relatedTarget: relatedTarget
@@ -2676,11 +2699,11 @@
return;
}
this._isShown = false;
- var transition = this._element.classList.contains(CLASS_NAME_FADE);
+ var transition = this._element.classList.contains(CLASS_NAME_FADE$1);
if (transition) {
this._isTransitioning = true;
}
@@ -2688,18 +2711,18 @@
this._setResizeEvent();
EventHandler.off(document, EVENT_FOCUSIN);
- this._element.classList.remove(CLASS_NAME_SHOW$2);
+ this._element.classList.remove(CLASS_NAME_SHOW$3);
EventHandler.off(this._element, EVENT_CLICK_DISMISS);
EventHandler.off(this._dialog, EVENT_MOUSEDOWN_DISMISS);
if (transition) {
var transitionDuration = getTransitionDurationFromElement(this._element);
- EventHandler.one(this._element, TRANSITION_END, function (event) {
+ EventHandler.one(this._element, 'transitionend', function (event) {
return _this3._hideModal(event);
});
emulateTransitionEnd(this._element, transitionDuration);
} else {
this._hideModal();
@@ -2742,11 +2765,11 @@
};
_proto._showElement = function _showElement(relatedTarget) {
var _this4 = this;
- var transition = this._element.classList.contains(CLASS_NAME_FADE);
+ var transition = this._element.classList.contains(CLASS_NAME_FADE$1);
var modalBody = SelectorEngine.findOne(SELECTOR_MODAL_BODY, this._dialog);
if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
// Don't move modal's DOM position
@@ -2769,11 +2792,11 @@
if (transition) {
reflow(this._element);
}
- this._element.classList.add(CLASS_NAME_SHOW$2);
+ this._element.classList.add(CLASS_NAME_SHOW$3);
if (this._config.focus) {
this._enforceFocus();
}
@@ -2788,11 +2811,11 @@
});
};
if (transition) {
var transitionDuration = getTransitionDurationFromElement(this._dialog);
- EventHandler.one(this._dialog, TRANSITION_END, transitionComplete);
+ EventHandler.one(this._dialog, 'transitionend', transitionComplete);
emulateTransitionEnd(this._dialog, transitionDuration);
} else {
transitionComplete();
}
};
@@ -2870,11 +2893,11 @@
};
_proto._showBackdrop = function _showBackdrop(callback) {
var _this9 = this;
- var animate = this._element.classList.contains(CLASS_NAME_FADE) ? CLASS_NAME_FADE : '';
+ var animate = this._element.classList.contains(CLASS_NAME_FADE$1) ? CLASS_NAME_FADE$1 : '';
if (this._isShown && this._config.backdrop) {
this._backdrop = document.createElement('div');
this._backdrop.className = CLASS_NAME_BACKDROP;
@@ -2902,33 +2925,33 @@
if (animate) {
reflow(this._backdrop);
}
- this._backdrop.classList.add(CLASS_NAME_SHOW$2);
+ this._backdrop.classList.add(CLASS_NAME_SHOW$3);
if (!animate) {
callback();
return;
}
var backdropTransitionDuration = getTransitionDurationFromElement(this._backdrop);
- EventHandler.one(this._backdrop, TRANSITION_END, callback);
+ EventHandler.one(this._backdrop, 'transitionend', callback);
emulateTransitionEnd(this._backdrop, backdropTransitionDuration);
} else if (!this._isShown && this._backdrop) {
- this._backdrop.classList.remove(CLASS_NAME_SHOW$2);
+ this._backdrop.classList.remove(CLASS_NAME_SHOW$3);
var callbackRemove = function callbackRemove() {
_this9._removeBackdrop();
callback();
};
- if (this._element.classList.contains(CLASS_NAME_FADE)) {
+ if (this._element.classList.contains(CLASS_NAME_FADE$1)) {
var _backdropTransitionDuration = getTransitionDurationFromElement(this._backdrop);
- EventHandler.one(this._backdrop, TRANSITION_END, callbackRemove);
+ EventHandler.one(this._backdrop, 'transitionend', callbackRemove);
emulateTransitionEnd(this._backdrop, _backdropTransitionDuration);
} else {
callbackRemove();
}
} else {
@@ -2952,16 +2975,16 @@
}
this._element.classList.add(CLASS_NAME_STATIC);
var modalTransitionDuration = getTransitionDurationFromElement(this._dialog);
- EventHandler.off(this._element, TRANSITION_END);
- EventHandler.one(this._element, TRANSITION_END, function () {
+ EventHandler.off(this._element, 'transitionend');
+ EventHandler.one(this._element, 'transitionend', function () {
_this10._element.classList.remove(CLASS_NAME_STATIC);
if (!isModalOverflowing) {
- EventHandler.one(_this10._element, TRANSITION_END, function () {
+ EventHandler.one(_this10._element, 'transitionend', function () {
_this10._element.style.overflowY = '';
});
emulateTransitionEnd(_this10._element, modalTransitionDuration);
}
});
@@ -2998,64 +3021,54 @@
_proto._setScrollbar = function _setScrollbar() {
var _this11 = this;
if (this._isBodyOverflowing) {
- // Note: DOMNode.style.paddingRight returns the actual value or '' if not set
- // while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
- // Adjust fixed content padding
- SelectorEngine.find(SELECTOR_FIXED_CONTENT).forEach(function (element) {
- var actualPadding = element.style.paddingRight;
- var calculatedPadding = window.getComputedStyle(element)['padding-right'];
- Manipulator.setDataAttribute(element, 'padding-right', actualPadding);
- element.style.paddingRight = Number.parseFloat(calculatedPadding) + _this11._scrollbarWidth + "px";
- }); // Adjust sticky content margin
+ this._setElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight', function (calculatedValue) {
+ return calculatedValue + _this11._scrollbarWidth;
+ });
- SelectorEngine.find(SELECTOR_STICKY_CONTENT).forEach(function (element) {
- var actualMargin = element.style.marginRight;
- var calculatedMargin = window.getComputedStyle(element)['margin-right'];
- Manipulator.setDataAttribute(element, 'margin-right', actualMargin);
- element.style.marginRight = Number.parseFloat(calculatedMargin) - _this11._scrollbarWidth + "px";
- }); // Adjust body padding
+ this._setElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight', function (calculatedValue) {
+ return calculatedValue - _this11._scrollbarWidth;
+ });
- var actualPadding = document.body.style.paddingRight;
- var calculatedPadding = window.getComputedStyle(document.body)['padding-right'];
- Manipulator.setDataAttribute(document.body, 'padding-right', actualPadding);
- document.body.style.paddingRight = Number.parseFloat(calculatedPadding) + this._scrollbarWidth + "px";
+ this._setElementAttributes('body', 'paddingRight', function (calculatedValue) {
+ return calculatedValue + _this11._scrollbarWidth;
+ });
}
document.body.classList.add(CLASS_NAME_OPEN);
};
+ _proto._setElementAttributes = function _setElementAttributes(selector, styleProp, callback) {
+ SelectorEngine.find(selector).forEach(function (element) {
+ var actualValue = element.style[styleProp];
+ var calculatedValue = window.getComputedStyle(element)[styleProp];
+ Manipulator.setDataAttribute(element, styleProp, actualValue);
+ element.style[styleProp] = callback(Number.parseFloat(calculatedValue)) + 'px';
+ });
+ };
+
_proto._resetScrollbar = function _resetScrollbar() {
- // Restore fixed content padding
- SelectorEngine.find(SELECTOR_FIXED_CONTENT).forEach(function (element) {
- var padding = Manipulator.getDataAttribute(element, 'padding-right');
+ this._resetElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight');
- if (typeof padding !== 'undefined') {
- Manipulator.removeDataAttribute(element, 'padding-right');
- element.style.paddingRight = padding;
- }
- }); // Restore sticky content and navbar-toggler margin
+ this._resetElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight');
- SelectorEngine.find("" + SELECTOR_STICKY_CONTENT).forEach(function (element) {
- var margin = Manipulator.getDataAttribute(element, 'margin-right');
+ this._resetElementAttributes('body', 'paddingRight');
+ };
- if (typeof margin !== 'undefined') {
- Manipulator.removeDataAttribute(element, 'margin-right');
- element.style.marginRight = margin;
- }
- }); // Restore body padding
+ _proto._resetElementAttributes = function _resetElementAttributes(selector, styleProp) {
+ SelectorEngine.find(selector).forEach(function (element) {
+ var value = Manipulator.getDataAttribute(element, styleProp);
- var padding = Manipulator.getDataAttribute(document.body, 'padding-right');
-
- if (typeof padding === 'undefined') {
- document.body.style.paddingRight = '';
- } else {
- Manipulator.removeDataAttribute(document.body, 'padding-right');
- document.body.style.paddingRight = padding;
- }
+ if (typeof value === 'undefined' && element === document.body) {
+ element.style[styleProp] = '';
+ } else {
+ Manipulator.removeDataAttribute(element, styleProp);
+ element.style[styleProp] = value;
+ }
+ });
};
_proto._getScrollbarWidth = function _getScrollbarWidth() {
// thx d.walsh
var scrollDiv = document.createElement('div');
@@ -3135,38 +3148,24 @@
var config = _extends({}, Manipulator.getDataAttributes(target), Manipulator.getDataAttributes(this));
data = new Modal(target, config);
}
- data.show(this);
+ data.toggle(this);
});
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .Modal to jQuery only if jQuery is present
*/
- onDOMContentLoaded(function () {
- var $ = getjQuery();
- /* istanbul ignore if */
+ defineJQueryPlugin(NAME$5, Modal);
- if ($) {
- var JQUERY_NO_CONFLICT = $.fn[NAME$5];
- $.fn[NAME$5] = Modal.jQueryInterface;
- $.fn[NAME$5].Constructor = Modal;
-
- $.fn[NAME$5].noConflict = function () {
- $.fn[NAME$5] = JQUERY_NO_CONFLICT;
- return Modal.jQueryInterface;
- };
- }
- });
-
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.0-beta1): util/sanitizer.js
+ * Bootstrap (v5.0.0-beta2): util/sanitizer.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
var uriAttrs = new Set(['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href']);
var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
@@ -3188,22 +3187,22 @@
var allowedAttribute = function allowedAttribute(attr, allowedAttributeList) {
var attrName = attr.nodeName.toLowerCase();
if (allowedAttributeList.includes(attrName)) {
if (uriAttrs.has(attrName)) {
- return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN));
+ return Boolean(SAFE_URL_PATTERN.test(attr.nodeValue) || DATA_URL_PATTERN.test(attr.nodeValue));
}
return true;
}
var regExp = allowedAttributeList.filter(function (attrRegex) {
return attrRegex instanceof RegExp;
}); // Check if a regular expression validates the attribute.
for (var i = 0, len = regExp.length; i < len; i++) {
- if (attrName.match(regExp[i])) {
+ if (regExp[i].test(attrName)) {
return true;
}
}
return false;
@@ -3308,18 +3307,19 @@
trigger: 'string',
delay: '(number|object)',
html: 'boolean',
selector: '(string|boolean)',
placement: '(string|function)',
+ offset: '(array|string|function)',
container: '(string|element|boolean)',
- fallbackPlacements: '(null|array)',
+ fallbackPlacements: 'array',
boundary: '(string|element)',
customClass: '(string|function)',
sanitize: 'boolean',
sanitizeFn: '(null|function)',
allowList: 'object',
- popperConfig: '(null|object)'
+ popperConfig: '(null|object|function)'
};
var AttachmentMap = {
AUTO: 'auto',
TOP: 'top',
RIGHT: isRTL ? 'left' : 'right',
@@ -3333,12 +3333,13 @@
title: '',
delay: 0,
html: false,
selector: false,
placement: 'top',
+ offset: [0, 0],
container: false,
- fallbackPlacements: null,
+ fallbackPlacements: ['top', 'right', 'bottom', 'left'],
boundary: 'clippingParents',
customClass: '',
sanitize: true,
sanitizeFn: null,
allowList: DefaultAllowlist,
@@ -3354,13 +3355,13 @@
FOCUSIN: "focusin" + EVENT_KEY$6,
FOCUSOUT: "focusout" + EVENT_KEY$6,
MOUSEENTER: "mouseenter" + EVENT_KEY$6,
MOUSELEAVE: "mouseleave" + EVENT_KEY$6
};
- var CLASS_NAME_FADE$1 = 'fade';
+ var CLASS_NAME_FADE$2 = 'fade';
var CLASS_NAME_MODAL = 'modal';
- var CLASS_NAME_SHOW$3 = 'show';
+ var CLASS_NAME_SHOW$4 = 'show';
var HOVER_STATE_SHOW = 'show';
var HOVER_STATE_OUT = 'out';
var SELECTOR_TOOLTIP_INNER = '.tooltip-inner';
var TRIGGER_HOVER = 'hover';
var TRIGGER_FOCUS = 'focus';
@@ -3418,27 +3419,21 @@
if (!this._isEnabled) {
return;
}
if (event) {
- var dataKey = this.constructor.DATA_KEY;
- var context = Data.getData(event.delegateTarget, dataKey);
+ var context = this._initializeOnDelegatedTarget(event);
- if (!context) {
- context = new this.constructor(event.delegateTarget, this._getDelegateConfig());
- Data.setData(event.delegateTarget, dataKey, context);
- }
-
context._activeTrigger.click = !context._activeTrigger.click;
if (context._isWithActiveTrigger()) {
context._enter(null, context);
} else {
context._leave(null, context);
}
} else {
- if (this.getTipElement().classList.contains(CLASS_NAME_SHOW$3)) {
+ if (this.getTipElement().classList.contains(CLASS_NAME_SHOW$4)) {
this._leave(null, this);
return;
}
@@ -3449,11 +3444,11 @@
_proto.dispose = function dispose() {
clearTimeout(this._timeout);
EventHandler.off(this._element, this.constructor.EVENT_KEY);
EventHandler.off(this._element.closest("." + CLASS_NAME_MODAL), 'hide.bs.modal', this._hideModalHandler);
- if (this.tip) {
+ if (this.tip && this.tip.parentNode) {
this.tip.parentNode.removeChild(this.tip);
}
this._isEnabled = null;
this._timeout = null;
@@ -3476,85 +3471,87 @@
if (this._element.style.display === 'none') {
throw new Error('Please use show on visible elements');
}
- if (this.isWithContent() && this._isEnabled) {
- var showEvent = EventHandler.trigger(this._element, this.constructor.Event.SHOW);
- var shadowRoot = findShadowRoot(this._element);
- var isInTheDom = shadowRoot === null ? this._element.ownerDocument.documentElement.contains(this._element) : shadowRoot.contains(this._element);
+ if (!(this.isWithContent() && this._isEnabled)) {
+ return;
+ }
- if (showEvent.defaultPrevented || !isInTheDom) {
- return;
- }
+ var showEvent = EventHandler.trigger(this._element, this.constructor.Event.SHOW);
+ var shadowRoot = findShadowRoot(this._element);
+ var isInTheDom = shadowRoot === null ? this._element.ownerDocument.documentElement.contains(this._element) : shadowRoot.contains(this._element);
- var tip = this.getTipElement();
- var tipId = getUID(this.constructor.NAME);
- tip.setAttribute('id', tipId);
+ if (showEvent.defaultPrevented || !isInTheDom) {
+ return;
+ }
- this._element.setAttribute('aria-describedby', tipId);
+ var tip = this.getTipElement();
+ var tipId = getUID(this.constructor.NAME);
+ tip.setAttribute('id', tipId);
- this.setContent();
+ this._element.setAttribute('aria-describedby', tipId);
- if (this.config.animation) {
- tip.classList.add(CLASS_NAME_FADE$1);
- }
+ this.setContent();
- var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this._element) : this.config.placement;
+ if (this.config.animation) {
+ tip.classList.add(CLASS_NAME_FADE$2);
+ }
- var attachment = this._getAttachment(placement);
+ var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this._element) : this.config.placement;
- this._addAttachmentClass(attachment);
+ var attachment = this._getAttachment(placement);
- var container = this._getContainer();
+ this._addAttachmentClass(attachment);
- Data.setData(tip, this.constructor.DATA_KEY, this);
+ var container = this._getContainer();
- if (!this._element.ownerDocument.documentElement.contains(this.tip)) {
- container.appendChild(tip);
- }
+ Data.setData(tip, this.constructor.DATA_KEY, this);
- EventHandler.trigger(this._element, this.constructor.Event.INSERTED);
- this._popper = Popper.createPopper(this._element, tip, this._getPopperConfig(attachment));
- tip.classList.add(CLASS_NAME_SHOW$3);
- var customClass = typeof this.config.customClass === 'function' ? this.config.customClass() : this.config.customClass;
+ if (!this._element.ownerDocument.documentElement.contains(this.tip)) {
+ container.appendChild(tip);
+ }
- if (customClass) {
- var _tip$classList;
+ EventHandler.trigger(this._element, this.constructor.Event.INSERTED);
+ this._popper = Popper.createPopper(this._element, tip, this._getPopperConfig(attachment));
+ tip.classList.add(CLASS_NAME_SHOW$4);
+ var customClass = typeof this.config.customClass === 'function' ? this.config.customClass() : this.config.customClass;
- (_tip$classList = tip.classList).add.apply(_tip$classList, customClass.split(' '));
- } // If this is a touch-enabled device we add extra
- // empty mouseover listeners to the body's immediate children;
- // only needed because of broken event delegation on iOS
- // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
+ if (customClass) {
+ var _tip$classList;
+ (_tip$classList = tip.classList).add.apply(_tip$classList, customClass.split(' '));
+ } // If this is a touch-enabled device we add extra
+ // empty mouseover listeners to the body's immediate children;
+ // only needed because of broken event delegation on iOS
+ // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
- if ('ontouchstart' in document.documentElement) {
- var _ref;
- (_ref = []).concat.apply(_ref, document.body.children).forEach(function (element) {
- EventHandler.on(element, 'mouseover', noop());
- });
- }
+ if ('ontouchstart' in document.documentElement) {
+ var _ref;
- var complete = function complete() {
- var prevHoverState = _this2._hoverState;
- _this2._hoverState = null;
- EventHandler.trigger(_this2._element, _this2.constructor.Event.SHOWN);
+ (_ref = []).concat.apply(_ref, document.body.children).forEach(function (element) {
+ EventHandler.on(element, 'mouseover', noop());
+ });
+ }
- if (prevHoverState === HOVER_STATE_OUT) {
- _this2._leave(null, _this2);
- }
- };
+ var complete = function complete() {
+ var prevHoverState = _this2._hoverState;
+ _this2._hoverState = null;
+ EventHandler.trigger(_this2._element, _this2.constructor.Event.SHOWN);
- if (this.tip.classList.contains(CLASS_NAME_FADE$1)) {
- var transitionDuration = getTransitionDurationFromElement(this.tip);
- EventHandler.one(this.tip, TRANSITION_END, complete);
- emulateTransitionEnd(this.tip, transitionDuration);
- } else {
- complete();
+ if (prevHoverState === HOVER_STATE_OUT) {
+ _this2._leave(null, _this2);
}
+ };
+
+ if (this.tip.classList.contains(CLASS_NAME_FADE$2)) {
+ var transitionDuration = getTransitionDurationFromElement(this.tip);
+ EventHandler.one(this.tip, 'transitionend', complete);
+ emulateTransitionEnd(this.tip, transitionDuration);
+ } else {
+ complete();
}
};
_proto.hide = function hide() {
var _this3 = this;
@@ -3587,11 +3584,11 @@
if (hideEvent.defaultPrevented) {
return;
}
- tip.classList.remove(CLASS_NAME_SHOW$3); // If this is a touch-enabled device we remove the extra
+ tip.classList.remove(CLASS_NAME_SHOW$4); // If this is a touch-enabled device we remove the extra
// empty mouseover listeners we added for iOS support
if ('ontouchstart' in document.documentElement) {
var _ref2;
@@ -3602,13 +3599,13 @@
this._activeTrigger[TRIGGER_CLICK] = false;
this._activeTrigger[TRIGGER_FOCUS] = false;
this._activeTrigger[TRIGGER_HOVER] = false;
- if (this.tip.classList.contains(CLASS_NAME_FADE$1)) {
+ if (this.tip.classList.contains(CLASS_NAME_FADE$2)) {
var transitionDuration = getTransitionDurationFromElement(tip);
- EventHandler.one(tip, TRANSITION_END, complete);
+ EventHandler.one(tip, 'transitionend', complete);
emulateTransitionEnd(tip, transitionDuration);
} else {
complete();
}
@@ -3638,11 +3635,11 @@
};
_proto.setContent = function setContent() {
var tip = this.getTipElement();
this.setElementContent(SelectorEngine.findOne(SELECTOR_TOOLTIP_INNER, tip), this.getTitle());
- tip.classList.remove(CLASS_NAME_FADE$1, CLASS_NAME_SHOW$3);
+ tip.classList.remove(CLASS_NAME_FADE$2, CLASS_NAME_SHOW$4);
};
_proto.setElementContent = function setElementContent(element, content) {
if (element === null) {
return;
@@ -3698,30 +3695,62 @@
return attachment;
} // Private
;
- _proto._getPopperConfig = function _getPopperConfig(attachment) {
+ _proto._initializeOnDelegatedTarget = function _initializeOnDelegatedTarget(event, context) {
+ var dataKey = this.constructor.DATA_KEY;
+ context = context || Data.getData(event.delegateTarget, dataKey);
+
+ if (!context) {
+ context = new this.constructor(event.delegateTarget, this._getDelegateConfig());
+ Data.setData(event.delegateTarget, dataKey, context);
+ }
+
+ return context;
+ };
+
+ _proto._getOffset = function _getOffset() {
var _this4 = this;
- var flipModifier = {
- name: 'flip',
- options: {
- altBoundary: true
- }
- };
+ var offset = this.config.offset;
- if (this.config.fallbackPlacements) {
- flipModifier.options.fallbackPlacements = this.config.fallbackPlacements;
+ if (typeof offset === 'string') {
+ return offset.split(',').map(function (val) {
+ return Number.parseInt(val, 10);
+ });
}
- var defaultBsConfig = {
+ if (typeof offset === 'function') {
+ return function (popperData) {
+ return offset(popperData, _this4._element);
+ };
+ }
+
+ return offset;
+ };
+
+ _proto._getPopperConfig = function _getPopperConfig(attachment) {
+ var _this5 = this;
+
+ var defaultBsPopperConfig = {
placement: attachment,
- modifiers: [flipModifier, {
+ modifiers: [{
+ name: 'flip',
+ options: {
+ altBoundary: true,
+ fallbackPlacements: this.config.fallbackPlacements
+ }
+ }, {
+ name: 'offset',
+ options: {
+ offset: this._getOffset()
+ }
+ }, {
name: 'preventOverflow',
options: {
- rootBoundary: this.config.boundary
+ boundary: this.config.boundary
}
}, {
name: 'arrow',
options: {
element: "." + this.constructor.NAME + "-arrow"
@@ -3729,20 +3758,20 @@
}, {
name: 'onChange',
enabled: true,
phase: 'afterWrite',
fn: function fn(data) {
- return _this4._handlePopperPlacementChange(data);
+ return _this5._handlePopperPlacementChange(data);
}
}],
onFirstUpdate: function onFirstUpdate(data) {
if (data.options.placement !== data.placement) {
- _this4._handlePopperPlacementChange(data);
+ _this5._handlePopperPlacementChange(data);
}
}
};
- return _extends({}, defaultBsConfig, this.config.popperConfig);
+ return _extends({}, defaultBsPopperConfig, typeof this.config.popperConfig === 'function' ? this.config.popperConfig(defaultBsPopperConfig) : this.config.popperConfig);
};
_proto._addAttachmentClass = function _addAttachmentClass(attachment) {
this.getTipElement().classList.add(CLASS_PREFIX + "-" + this.updateAttachment(attachment));
};
@@ -3762,33 +3791,33 @@
_proto._getAttachment = function _getAttachment(placement) {
return AttachmentMap[placement.toUpperCase()];
};
_proto._setListeners = function _setListeners() {
- var _this5 = this;
+ var _this6 = this;
var triggers = this.config.trigger.split(' ');
triggers.forEach(function (trigger) {
if (trigger === 'click') {
- EventHandler.on(_this5._element, _this5.constructor.Event.CLICK, _this5.config.selector, function (event) {
- return _this5.toggle(event);
+ EventHandler.on(_this6._element, _this6.constructor.Event.CLICK, _this6.config.selector, function (event) {
+ return _this6.toggle(event);
});
} else if (trigger !== TRIGGER_MANUAL) {
- var eventIn = trigger === TRIGGER_HOVER ? _this5.constructor.Event.MOUSEENTER : _this5.constructor.Event.FOCUSIN;
- var eventOut = trigger === TRIGGER_HOVER ? _this5.constructor.Event.MOUSELEAVE : _this5.constructor.Event.FOCUSOUT;
- EventHandler.on(_this5._element, eventIn, _this5.config.selector, function (event) {
- return _this5._enter(event);
+ var eventIn = trigger === TRIGGER_HOVER ? _this6.constructor.Event.MOUSEENTER : _this6.constructor.Event.FOCUSIN;
+ var eventOut = trigger === TRIGGER_HOVER ? _this6.constructor.Event.MOUSELEAVE : _this6.constructor.Event.FOCUSOUT;
+ EventHandler.on(_this6._element, eventIn, _this6.config.selector, function (event) {
+ return _this6._enter(event);
});
- EventHandler.on(_this5._element, eventOut, _this5.config.selector, function (event) {
- return _this5._leave(event);
+ EventHandler.on(_this6._element, eventOut, _this6.config.selector, function (event) {
+ return _this6._leave(event);
});
}
});
this._hideModalHandler = function () {
- if (_this5._element) {
- _this5.hide();
+ if (_this6._element) {
+ _this6.hide();
}
};
EventHandler.on(this._element.closest("." + CLASS_NAME_MODAL), 'hide.bs.modal', this._hideModalHandler);
@@ -3817,23 +3846,17 @@
this._element.setAttribute('title', '');
}
};
_proto._enter = function _enter(event, context) {
- var dataKey = this.constructor.DATA_KEY;
- context = context || Data.getData(event.delegateTarget, dataKey);
+ context = this._initializeOnDelegatedTarget(event, context);
- if (!context) {
- context = new this.constructor(event.delegateTarget, this._getDelegateConfig());
- Data.setData(event.delegateTarget, dataKey, context);
- }
-
if (event) {
context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true;
}
- if (context.getTipElement().classList.contains(CLASS_NAME_SHOW$3) || context._hoverState === HOVER_STATE_SHOW) {
+ if (context.getTipElement().classList.contains(CLASS_NAME_SHOW$4) || context._hoverState === HOVER_STATE_SHOW) {
context._hoverState = HOVER_STATE_SHOW;
return;
}
clearTimeout(context._timeout);
@@ -3850,18 +3873,12 @@
}
}, context.config.delay.show);
};
_proto._leave = function _leave(event, context) {
- var dataKey = this.constructor.DATA_KEY;
- context = context || Data.getData(event.delegateTarget, dataKey);
+ context = this._initializeOnDelegatedTarget(event, context);
- if (!context) {
- context = new this.constructor(event.delegateTarget, this._getDelegateConfig());
- Data.setData(event.delegateTarget, dataKey, context);
- }
-
if (event) {
context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = false;
}
if (context._isWithActiveTrigger()) {
@@ -4037,26 +4054,12 @@
* ------------------------------------------------------------------------
* add .Tooltip to jQuery only if jQuery is present
*/
- onDOMContentLoaded(function () {
- var $ = getjQuery();
- /* istanbul ignore if */
+ defineJQueryPlugin(NAME$6, Tooltip);
- if ($) {
- var JQUERY_NO_CONFLICT = $.fn[NAME$6];
- $.fn[NAME$6] = Tooltip.jQueryInterface;
- $.fn[NAME$6].Constructor = Tooltip;
-
- $.fn[NAME$6].noConflict = function () {
- $.fn[NAME$6] = JQUERY_NO_CONFLICT;
- return Tooltip.jQueryInterface;
- };
- }
- });
-
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
@@ -4067,10 +4070,11 @@
var CLASS_PREFIX$1 = 'bs-popover';
var BSCLS_PREFIX_REGEX$1 = new RegExp("(^|\\s)" + CLASS_PREFIX$1 + "\\S+", 'g');
var Default$5 = _extends({}, Tooltip.Default, {
placement: 'right',
+ offset: [0, 8],
trigger: 'click',
content: '',
template: '<div class="popover" role="tooltip">' + '<div class="popover-arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div>' + '</div>'
});
@@ -4088,12 +4092,12 @@
FOCUSIN: "focusin" + EVENT_KEY$7,
FOCUSOUT: "focusout" + EVENT_KEY$7,
MOUSEENTER: "mouseenter" + EVENT_KEY$7,
MOUSELEAVE: "mouseleave" + EVENT_KEY$7
};
- var CLASS_NAME_FADE$2 = 'fade';
- var CLASS_NAME_SHOW$4 = 'show';
+ var CLASS_NAME_FADE$3 = 'fade';
+ var CLASS_NAME_SHOW$5 = 'show';
var SELECTOR_TITLE = '.popover-header';
var SELECTOR_CONTENT = '.popover-body';
/**
* ------------------------------------------------------------------------
* Class Definition
@@ -4124,11 +4128,11 @@
if (typeof content === 'function') {
content = content.call(this._element);
}
this.setElementContent(SelectorEngine.findOne(SELECTOR_CONTENT, tip), content);
- tip.classList.remove(CLASS_NAME_FADE$2, CLASS_NAME_SHOW$4);
+ tip.classList.remove(CLASS_NAME_FADE$3, CLASS_NAME_SHOW$5);
} // Private
;
_proto._addAttachmentClass = function _addAttachmentClass(attachment) {
this.getTipElement().classList.add(CLASS_PREFIX$1 + "-" + this.updateAttachment(attachment));
@@ -4177,12 +4181,12 @@
});
};
_createClass(Popover, null, [{
key: "Default",
- // Getters
- get: function get() {
+ get: // Getters
+ function get() {
return Default$5;
}
}, {
key: "NAME",
get: function get() {
@@ -4218,26 +4222,12 @@
* ------------------------------------------------------------------------
* add .Popover to jQuery only if jQuery is present
*/
- onDOMContentLoaded(function () {
- var $ = getjQuery();
- /* istanbul ignore if */
+ defineJQueryPlugin(NAME$7, Popover);
- if ($) {
- var JQUERY_NO_CONFLICT = $.fn[NAME$7];
- $.fn[NAME$7] = Popover.jQueryInterface;
- $.fn[NAME$7].Constructor = Popover;
-
- $.fn[NAME$7].noConflict = function () {
- $.fn[NAME$7] = JQUERY_NO_CONFLICT;
- return Popover.jQueryInterface;
- };
- }
- });
-
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
@@ -4288,12 +4278,12 @@
_this._selector = _this._config.target + " " + SELECTOR_NAV_LINKS + ", " + _this._config.target + " " + SELECTOR_LIST_ITEMS + ", " + _this._config.target + " ." + CLASS_NAME_DROPDOWN_ITEM;
_this._offsets = [];
_this._targets = [];
_this._activeTarget = null;
_this._scrollHeight = 0;
- EventHandler.on(_this._scrollElement, EVENT_SCROLL, function (event) {
- return _this._process(event);
+ EventHandler.on(_this._scrollElement, EVENT_SCROLL, function () {
+ return _this._process();
});
_this.refresh();
_this._process();
@@ -4518,26 +4508,12 @@
* jQuery
* ------------------------------------------------------------------------
* add .ScrollSpy to jQuery only if jQuery is present
*/
- onDOMContentLoaded(function () {
- var $ = getjQuery();
- /* istanbul ignore if */
+ defineJQueryPlugin(NAME$8, ScrollSpy);
- if ($) {
- var JQUERY_NO_CONFLICT = $.fn[NAME$8];
- $.fn[NAME$8] = ScrollSpy.jQueryInterface;
- $.fn[NAME$8].Constructor = ScrollSpy;
-
- $.fn[NAME$8].noConflict = function () {
- $.fn[NAME$8] = JQUERY_NO_CONFLICT;
- return ScrollSpy.jQueryInterface;
- };
- }
- });
-
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
@@ -4552,12 +4528,12 @@
var EVENT_SHOWN$3 = "shown" + EVENT_KEY$9;
var EVENT_CLICK_DATA_API$6 = "click" + EVENT_KEY$9 + DATA_API_KEY$7;
var CLASS_NAME_DROPDOWN_MENU = 'dropdown-menu';
var CLASS_NAME_ACTIVE$3 = 'active';
var CLASS_NAME_DISABLED$1 = 'disabled';
- var CLASS_NAME_FADE$3 = 'fade';
- var CLASS_NAME_SHOW$5 = 'show';
+ var CLASS_NAME_FADE$4 = 'fade';
+ var CLASS_NAME_SHOW$6 = 'show';
var SELECTOR_DROPDOWN$1 = '.dropdown';
var SELECTOR_NAV_LIST_GROUP$1 = '.nav, .list-group';
var SELECTOR_ACTIVE$1 = '.active';
var SELECTOR_ACTIVE_UL = ':scope > li > .active';
var SELECTOR_DATA_TOGGLE$4 = '[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]';
@@ -4595,18 +4571,13 @@
var itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? SELECTOR_ACTIVE_UL : SELECTOR_ACTIVE$1;
previous = SelectorEngine.find(itemSelector, listElement);
previous = previous[previous.length - 1];
}
- var hideEvent = null;
-
- if (previous) {
- hideEvent = EventHandler.trigger(previous, EVENT_HIDE$3, {
- relatedTarget: this._element
- });
- }
-
+ var hideEvent = previous ? EventHandler.trigger(previous, EVENT_HIDE$3, {
+ relatedTarget: this._element
+ }) : null;
var showEvent = EventHandler.trigger(this._element, EVENT_SHOW$3, {
relatedTarget: previous
});
if (showEvent.defaultPrevented || hideEvent !== null && hideEvent.defaultPrevented) {
@@ -4635,20 +4606,20 @@
_proto._activate = function _activate(element, container, callback) {
var _this2 = this;
var activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL') ? SelectorEngine.find(SELECTOR_ACTIVE_UL, container) : SelectorEngine.children(container, SELECTOR_ACTIVE$1);
var active = activeElements[0];
- var isTransitioning = callback && active && active.classList.contains(CLASS_NAME_FADE$3);
+ var isTransitioning = callback && active && active.classList.contains(CLASS_NAME_FADE$4);
var complete = function complete() {
return _this2._transitionComplete(element, active, callback);
};
if (active && isTransitioning) {
var transitionDuration = getTransitionDurationFromElement(active);
- active.classList.remove(CLASS_NAME_SHOW$5);
- EventHandler.one(active, TRANSITION_END, complete);
+ active.classList.remove(CLASS_NAME_SHOW$6);
+ EventHandler.one(active, 'transitionend', complete);
emulateTransitionEnd(active, transitionDuration);
} else {
complete();
}
};
@@ -4673,12 +4644,12 @@
element.setAttribute('aria-selected', true);
}
reflow(element);
- if (element.classList.contains(CLASS_NAME_FADE$3)) {
- element.classList.add(CLASS_NAME_SHOW$5);
+ if (element.classList.contains(CLASS_NAME_FADE$4)) {
+ element.classList.add(CLASS_NAME_SHOW$6);
}
if (element.parentNode && element.parentNode.classList.contains(CLASS_NAME_DROPDOWN_MENU)) {
var dropdownElement = element.closest(SELECTOR_DROPDOWN$1);
@@ -4711,12 +4682,12 @@
});
};
_createClass(Tab, null, [{
key: "DATA_KEY",
- // Getters
- get: function get() {
+ get: // Getters
+ function get() {
return DATA_KEY$9;
}
}]);
return Tab;
@@ -4738,26 +4709,12 @@
* jQuery
* ------------------------------------------------------------------------
* add .Tab to jQuery only if jQuery is present
*/
- onDOMContentLoaded(function () {
- var $ = getjQuery();
- /* istanbul ignore if */
+ defineJQueryPlugin(NAME$9, Tab);
- if ($) {
- var JQUERY_NO_CONFLICT = $.fn[NAME$9];
- $.fn[NAME$9] = Tab.jQueryInterface;
- $.fn[NAME$9].Constructor = Tab;
-
- $.fn[NAME$9].noConflict = function () {
- $.fn[NAME$9] = JQUERY_NO_CONFLICT;
- return Tab.jQueryInterface;
- };
- }
- });
-
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
@@ -4768,13 +4725,13 @@
var EVENT_CLICK_DISMISS$1 = "click.dismiss" + EVENT_KEY$a;
var EVENT_HIDE$4 = "hide" + EVENT_KEY$a;
var EVENT_HIDDEN$4 = "hidden" + EVENT_KEY$a;
var EVENT_SHOW$4 = "show" + EVENT_KEY$a;
var EVENT_SHOWN$4 = "shown" + EVENT_KEY$a;
- var CLASS_NAME_FADE$4 = 'fade';
+ var CLASS_NAME_FADE$5 = 'fade';
var CLASS_NAME_HIDE = 'hide';
- var CLASS_NAME_SHOW$6 = 'show';
+ var CLASS_NAME_SHOW$7 = 'show';
var CLASS_NAME_SHOWING = 'showing';
var DefaultType$7 = {
animation: 'boolean',
autohide: 'boolean',
delay: 'number'
@@ -4820,17 +4777,17 @@
}
this._clearTimeout();
if (this._config.animation) {
- this._element.classList.add(CLASS_NAME_FADE$4);
+ this._element.classList.add(CLASS_NAME_FADE$5);
}
var complete = function complete() {
_this2._element.classList.remove(CLASS_NAME_SHOWING);
- _this2._element.classList.add(CLASS_NAME_SHOW$6);
+ _this2._element.classList.add(CLASS_NAME_SHOW$7);
EventHandler.trigger(_this2._element, EVENT_SHOWN$4);
if (_this2._config.autohide) {
_this2._timeout = setTimeout(function () {
@@ -4845,21 +4802,21 @@
this._element.classList.add(CLASS_NAME_SHOWING);
if (this._config.animation) {
var transitionDuration = getTransitionDurationFromElement(this._element);
- EventHandler.one(this._element, TRANSITION_END, complete);
+ EventHandler.one(this._element, 'transitionend', complete);
emulateTransitionEnd(this._element, transitionDuration);
} else {
complete();
}
};
_proto.hide = function hide() {
var _this3 = this;
- if (!this._element.classList.contains(CLASS_NAME_SHOW$6)) {
+ if (!this._element.classList.contains(CLASS_NAME_SHOW$7)) {
return;
}
var hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$4);
@@ -4871,26 +4828,26 @@
_this3._element.classList.add(CLASS_NAME_HIDE);
EventHandler.trigger(_this3._element, EVENT_HIDDEN$4);
};
- this._element.classList.remove(CLASS_NAME_SHOW$6);
+ this._element.classList.remove(CLASS_NAME_SHOW$7);
if (this._config.animation) {
var transitionDuration = getTransitionDurationFromElement(this._element);
- EventHandler.one(this._element, TRANSITION_END, complete);
+ EventHandler.one(this._element, 'transitionend', complete);
emulateTransitionEnd(this._element, transitionDuration);
} else {
complete();
}
};
_proto.dispose = function dispose() {
this._clearTimeout();
- if (this._element.classList.contains(CLASS_NAME_SHOW$6)) {
- this._element.classList.remove(CLASS_NAME_SHOW$6);
+ if (this._element.classList.contains(CLASS_NAME_SHOW$7)) {
+ this._element.classList.remove(CLASS_NAME_SHOW$7);
}
EventHandler.off(this._element, EVENT_CLICK_DISMISS$1);
_BaseComponent.prototype.dispose.call(this);
@@ -4964,28 +4921,14 @@
* ------------------------------------------------------------------------
* add .Toast to jQuery only if jQuery is present
*/
- onDOMContentLoaded(function () {
- var $ = getjQuery();
- /* istanbul ignore if */
+ defineJQueryPlugin(NAME$a, Toast);
- if ($) {
- var JQUERY_NO_CONFLICT = $.fn[NAME$a];
- $.fn[NAME$a] = Toast.jQueryInterface;
- $.fn[NAME$a].Constructor = Toast;
-
- $.fn[NAME$a].noConflict = function () {
- $.fn[NAME$a] = JQUERY_NO_CONFLICT;
- return Toast.jQueryInterface;
- };
- }
- });
-
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.0-beta1): index.umd.js
+ * Bootstrap (v5.0.0-beta2): index.umd.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
var index_umd = {
Alert: Alert,