assets/javascripts/bootstrap.js in bootstrap-5.0.1 vs assets/javascripts/bootstrap.js in bootstrap-5.0.2
- old
+ new
@@ -1,7 +1,7 @@
/*!
- * Bootstrap v5.0.1 (https://getbootstrap.com/)
+ * Bootstrap 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')) :
@@ -31,11 +31,11 @@
var Popper__namespace = /*#__PURE__*/_interopNamespace(Popper);
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.1): dom/selector-engine.js
+ * Bootstrap (v5.0.2): dom/selector-engine.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
@@ -102,11 +102,11 @@
};
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.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;
@@ -224,28 +224,10 @@
}
return null;
};
- const emulateTransitionEnd = (element, duration) => {
- let called = false;
- const durationPadding = 5;
- const emulatedDuration = duration + durationPadding;
-
- function listener() {
- called = true;
- element.removeEventListener(TRANSITION_END, listener);
- }
-
- element.addEventListener(TRANSITION_END, listener);
- setTimeout(() => {
- if (!called) {
- triggerTransitionEnd(element);
- }
- }, emulatedDuration);
- };
-
const typeCheckConfig = (componentName, config, configTypes) => {
Object.keys(configTypes).forEach(property => {
const expectedTypes = configTypes[property];
const value = config[property];
const valueType = value && isElement(value) ? 'element' : toType(value);
@@ -255,21 +237,15 @@
}
});
};
const isVisible = element => {
- if (!element) {
+ if (!isElement(element) || element.getClientRects().length === 0) {
return false;
}
- if (element.style && element.parentNode && element.parentNode.style) {
- const elementStyle = getComputedStyle(element);
- const parentNodeStyle = getComputedStyle(element.parentNode);
- return elementStyle.display !== 'none' && parentNodeStyle.display !== 'none' && elementStyle.visibility !== 'hidden';
- }
-
- return false;
+ return getComputedStyle(element).getPropertyValue('visibility') === 'visible';
};
const isDisabled = element => {
if (!element || element.nodeType !== Node.ELEMENT_NODE) {
return true;
@@ -323,13 +299,22 @@
}
return null;
};
+ const DOMContentLoadedCallbacks = [];
+
const onDOMContentLoaded = callback => {
if (document.readyState === 'loading') {
- document.addEventListener('DOMContentLoaded', callback);
+ // add listener on the first call when the document is in loading state
+ if (!DOMContentLoadedCallbacks.length) {
+ document.addEventListener('DOMContentLoaded', () => {
+ DOMContentLoadedCallbacks.forEach(callback => callback());
+ });
+ }
+
+ DOMContentLoadedCallbacks.push(callback);
} else {
callback();
}
};
@@ -358,67 +343,70 @@
if (typeof callback === 'function') {
callback();
}
};
- /**
- * --------------------------------------------------------------------------
- * Bootstrap (v5.0.1): dom/data.js
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
- * --------------------------------------------------------------------------
- */
+ const executeAfterTransition = (callback, transitionElement, waitForTransition = true) => {
+ if (!waitForTransition) {
+ execute(callback);
+ return;
+ }
- /**
- * ------------------------------------------------------------------------
- * Constants
- * ------------------------------------------------------------------------
- */
- const elementMap = new Map();
- var Data = {
- set(element, key, instance) {
- if (!elementMap.has(element)) {
- elementMap.set(element, new Map());
- }
+ const durationPadding = 5;
+ const emulatedDuration = getTransitionDurationFromElement(transitionElement) + durationPadding;
+ let called = false;
- const instanceMap = elementMap.get(element); // make it clear we only want one instance per element
- // can be removed later when multiple key/instances are fine to be used
-
- if (!instanceMap.has(key) && instanceMap.size !== 0) {
- // eslint-disable-next-line no-console
- console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(instanceMap.keys())[0]}.`);
+ const handler = ({
+ target
+ }) => {
+ if (target !== transitionElement) {
return;
}
- instanceMap.set(key, instance);
- },
+ called = true;
+ transitionElement.removeEventListener(TRANSITION_END, handler);
+ execute(callback);
+ };
- get(element, key) {
- if (elementMap.has(element)) {
- return elementMap.get(element).get(key) || null;
+ transitionElement.addEventListener(TRANSITION_END, handler);
+ setTimeout(() => {
+ if (!called) {
+ triggerTransitionEnd(transitionElement);
}
+ }, emulatedDuration);
+ };
+ /**
+ * Return the previous/next element of a list.
+ *
+ * @param {array} list The list of elements
+ * @param activeElement The active element
+ * @param shouldGetNext Choose to get next or previous element
+ * @param isCycleAllowed
+ * @return {Element|elem} The proper element
+ */
- return null;
- },
- remove(element, key) {
- if (!elementMap.has(element)) {
- return;
- }
+ const getNextActiveElement = (list, activeElement, shouldGetNext, isCycleAllowed) => {
+ let index = list.indexOf(activeElement); // if the element does not exist in the list return an element depending on the direction and if cycle is allowed
- const instanceMap = elementMap.get(element);
- instanceMap.delete(key); // free up element references if there are no instances left for an element
+ if (index === -1) {
+ return list[!shouldGetNext && isCycleAllowed ? list.length - 1 : 0];
+ }
- if (instanceMap.size === 0) {
- elementMap.delete(element);
- }
+ const listLength = list.length;
+ index += shouldGetNext ? 1 : -1;
+
+ if (isCycleAllowed) {
+ index = (index + listLength) % listLength;
}
+ return list[Math.max(0, Math.min(index, listLength - 1))];
};
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.1): dom/event-handler.js
+ * Bootstrap (v5.0.2): dom/event-handler.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* ------------------------------------------------------------------------
@@ -703,22 +691,76 @@
};
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.1): base-component.js
+ * Bootstrap (v5.0.2): dom/data.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
+
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
+ const elementMap = new Map();
+ var Data = {
+ set(element, key, instance) {
+ if (!elementMap.has(element)) {
+ elementMap.set(element, new Map());
+ }
- const VERSION = '5.0.1';
+ const instanceMap = elementMap.get(element); // make it clear we only want one instance per element
+ // can be removed later when multiple key/instances are fine to be used
+ if (!instanceMap.has(key) && instanceMap.size !== 0) {
+ // eslint-disable-next-line no-console
+ console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(instanceMap.keys())[0]}.`);
+ return;
+ }
+
+ instanceMap.set(key, instance);
+ },
+
+ get(element, key) {
+ if (elementMap.has(element)) {
+ return elementMap.get(element).get(key) || null;
+ }
+
+ return null;
+ },
+
+ remove(element, key) {
+ if (!elementMap.has(element)) {
+ return;
+ }
+
+ const instanceMap = elementMap.get(element);
+ instanceMap.delete(key); // free up element references if there are no instances left for an element
+
+ if (instanceMap.size === 0) {
+ elementMap.delete(element);
+ }
+ }
+
+ };
+
+ /**
+ * --------------------------------------------------------------------------
+ * Bootstrap (v5.0.2): base-component.js
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
+ * --------------------------------------------------------------------------
+ */
+ /**
+ * ------------------------------------------------------------------------
+ * Constants
+ * ------------------------------------------------------------------------
+ */
+
+ const VERSION = '5.0.2';
+
class BaseComponent {
constructor(element) {
element = getElement(element);
if (!element) {
@@ -736,26 +778,23 @@
this[propertyName] = null;
});
}
_queueCallback(callback, element, isAnimated = true) {
- if (!isAnimated) {
- execute(callback);
- return;
- }
-
- const transitionDuration = getTransitionDurationFromElement(element);
- EventHandler.one(element, 'transitionend', () => execute(callback));
- emulateTransitionEnd(element, transitionDuration);
+ executeAfterTransition(callback, element, isAnimated);
}
/** Static */
static getInstance(element) {
return Data.get(element, this.DATA_KEY);
}
+ static getOrCreateInstance(element, config = {}) {
+ return this.getInstance(element) || new this(element, typeof config === 'object' ? config : null);
+ }
+
static get VERSION() {
return VERSION;
}
static get NAME() {
@@ -772,11 +811,11 @@
}
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.1): alert.js
+ * Bootstrap (v5.0.2): alert.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* ------------------------------------------------------------------------
@@ -835,26 +874,19 @@
this._queueCallback(() => this._destroyElement(element), element, isAnimated);
}
_destroyElement(element) {
- if (element.parentNode) {
- element.parentNode.removeChild(element);
- }
-
+ element.remove();
EventHandler.trigger(element, EVENT_CLOSED);
} // Static
static jQueryInterface(config) {
return this.each(function () {
- let data = Data.get(this, DATA_KEY$b);
+ const data = Alert.getOrCreateInstance(this);
- if (!data) {
- data = new Alert(this);
- }
-
if (config === 'close') {
data[config](this);
}
});
}
@@ -887,11 +919,11 @@
defineJQueryPlugin(Alert);
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.1): button.js
+ * Bootstrap (v5.0.2): button.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* ------------------------------------------------------------------------
@@ -925,16 +957,12 @@
} // Static
static jQueryInterface(config) {
return this.each(function () {
- let data = Data.get(this, DATA_KEY$a);
+ const data = Button.getOrCreateInstance(this);
- if (!data) {
- data = new Button(this);
- }
-
if (config === 'toggle') {
data[config]();
}
});
}
@@ -948,16 +976,11 @@
EventHandler.on(document, EVENT_CLICK_DATA_API$6, SELECTOR_DATA_TOGGLE$5, event => {
event.preventDefault();
const button = event.target.closest(SELECTOR_DATA_TOGGLE$5);
- let data = Data.get(button, DATA_KEY$a);
-
- if (!data) {
- data = new Button(button);
- }
-
+ const data = Button.getOrCreateInstance(button);
data.toggle();
});
/**
* ------------------------------------------------------------------------
* jQuery
@@ -967,11 +990,11 @@
defineJQueryPlugin(Button);
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.1): dom/manipulator.js
+ * Bootstrap (v5.0.2): dom/manipulator.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
function normalizeData(val) {
if (val === 'true') {
@@ -1041,11 +1064,11 @@
};
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.1): carousel.js
+ * Bootstrap (v5.0.2): carousel.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* ------------------------------------------------------------------------
@@ -1080,10 +1103,14 @@
};
const ORDER_NEXT = 'next';
const ORDER_PREV = 'prev';
const DIRECTION_LEFT = 'left';
const DIRECTION_RIGHT = 'right';
+ const KEY_TO_DIRECTION = {
+ [ARROW_LEFT_KEY]: DIRECTION_RIGHT,
+ [ARROW_RIGHT_KEY]: DIRECTION_LEFT
+ };
const EVENT_SLIDE = `slide${EVENT_KEY$9}`;
const EVENT_SLID = `slid${EVENT_KEY$9}`;
const EVENT_KEYDOWN = `keydown${EVENT_KEY$9}`;
const EVENT_MOUSEENTER = `mouseenter${EVENT_KEY$9}`;
const EVENT_MOUSELEAVE = `mouseleave${EVENT_KEY$9}`;
@@ -1148,13 +1175,11 @@
return NAME$a;
} // Public
next() {
- if (!this._isSliding) {
- this._slide(ORDER_NEXT);
- }
+ this._slide(ORDER_NEXT);
}
nextWhenVisible() {
// Don't call next when the page isn't visible
// or the carousel or its parent isn't visible
@@ -1162,13 +1187,11 @@
this.next();
}
}
prev() {
- if (!this._isSliding) {
- this._slide(ORDER_PREV);
- }
+ this._slide(ORDER_PREV);
}
pause(event) {
if (!event) {
this._isPaused = true;
@@ -1226,11 +1249,12 @@
} // Private
_getConfig(config) {
config = { ...Default$9,
- ...config
+ ...Manipulator.getDataAttributes(this._element),
+ ...(typeof config === 'object' ? config : {})
};
typeCheckConfig(NAME$a, config, DefaultType$9);
return config;
}
@@ -1324,42 +1348,27 @@
_keydown(event) {
if (/input|textarea/i.test(event.target.tagName)) {
return;
}
- if (event.key === ARROW_LEFT_KEY) {
- event.preventDefault();
+ const direction = KEY_TO_DIRECTION[event.key];
- this._slide(DIRECTION_RIGHT);
- } else if (event.key === ARROW_RIGHT_KEY) {
+ if (direction) {
event.preventDefault();
- this._slide(DIRECTION_LEFT);
+ this._slide(direction);
}
}
_getItemIndex(element) {
this._items = element && element.parentNode ? SelectorEngine.find(SELECTOR_ITEM, element.parentNode) : [];
return this._items.indexOf(element);
}
_getItemByOrder(order, activeElement) {
const isNext = order === ORDER_NEXT;
- const isPrev = order === ORDER_PREV;
-
- const activeIndex = this._getItemIndex(activeElement);
-
- const lastItemIndex = this._items.length - 1;
- const isGoingToWrap = isPrev && activeIndex === 0 || isNext && activeIndex === lastItemIndex;
-
- if (isGoingToWrap && !this._config.wrap) {
- return activeElement;
- }
-
- const delta = isPrev ? -1 : 1;
- const itemIndex = (activeIndex + delta) % this._items.length;
- return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
+ return getNextActiveElement(this._items, activeElement, isNext, this._config.wrap);
}
_triggerSlideEvent(relatedTarget, eventDirectionName) {
const targetIndex = this._getItemIndex(relatedTarget);
@@ -1428,10 +1437,14 @@
if (nextElement && nextElement.classList.contains(CLASS_NAME_ACTIVE$2)) {
this._isSliding = false;
return;
}
+ if (this._isSliding) {
+ return;
+ }
+
const slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
if (slideEvent.defaultPrevented) {
return;
}
@@ -1511,27 +1524,23 @@
return order === ORDER_PREV ? DIRECTION_RIGHT : DIRECTION_LEFT;
} // Static
static carouselInterface(element, config) {
- let data = Data.get(element, DATA_KEY$9);
- let _config = { ...Default$9,
- ...Manipulator.getDataAttributes(element)
- };
+ const data = Carousel.getOrCreateInstance(element, config);
+ let {
+ _config
+ } = data;
if (typeof config === 'object') {
_config = { ..._config,
...config
};
}
const action = typeof config === 'string' ? config : _config.slide;
- if (!data) {
- data = new Carousel(element, _config);
- }
-
if (typeof config === 'number') {
data.to(config);
} else if (typeof action === 'string') {
if (typeof data[action] === 'undefined') {
throw new TypeError(`No method named "${action}"`);
@@ -1567,11 +1576,11 @@
}
Carousel.carouselInterface(target, config);
if (slideIndex) {
- Data.get(target, DATA_KEY$9).to(slideIndex);
+ Carousel.getInstance(target).to(slideIndex);
}
event.preventDefault();
}
@@ -1586,11 +1595,11 @@
EventHandler.on(document, EVENT_CLICK_DATA_API$5, SELECTOR_DATA_SLIDE, Carousel.dataApiClickHandler);
EventHandler.on(window, EVENT_LOAD_DATA_API$2, () => {
const carousels = SelectorEngine.find(SELECTOR_DATA_RIDE);
for (let i = 0, len = carousels.length; i < len; i++) {
- Carousel.carouselInterface(carousels[i], Data.get(carousels[i], DATA_KEY$9));
+ Carousel.carouselInterface(carousels[i], Carousel.getInstance(carousels[i]));
}
});
/**
* ------------------------------------------------------------------------
* jQuery
@@ -1600,11 +1609,11 @@
defineJQueryPlugin(Carousel);
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.1): collapse.js
+ * Bootstrap (v5.0.2): collapse.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* ------------------------------------------------------------------------
@@ -1716,11 +1725,11 @@
const container = SelectorEngine.findOne(this._selector);
if (actives) {
const tempActiveData = actives.find(elem => container !== elem);
- activesData = tempActiveData ? Data.get(tempActiveData, DATA_KEY$8) : null;
+ activesData = tempActiveData ? Collapse.getInstance(tempActiveData) : null;
if (activesData && activesData._isTransitioning) {
return;
}
}
@@ -1879,11 +1888,11 @@
});
} // Static
static collapseInterface(element, config) {
- let data = Data.get(element, DATA_KEY$8);
+ let data = Collapse.getInstance(element);
const _config = { ...Default$8,
...Manipulator.getDataAttributes(element),
...(typeof config === 'object' && config ? config : {})
};
@@ -1926,11 +1935,11 @@
const triggerData = Manipulator.getDataAttributes(this);
const selector = getSelectorFromElement(this);
const selectorElements = SelectorEngine.find(selector);
selectorElements.forEach(element => {
- const data = Data.get(element, DATA_KEY$8);
+ const data = Collapse.getInstance(element);
let config;
if (data) {
// update parent attribute
if (data._parent === null && typeof triggerData.parent === 'string') {
@@ -1955,11 +1964,11 @@
defineJQueryPlugin(Collapse);
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.1): dropdown.js
+ * Bootstrap (v5.0.2): dropdown.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* ------------------------------------------------------------------------
@@ -2275,43 +2284,29 @@
return { ...defaultBsPopperConfig,
...(typeof this._config.popperConfig === 'function' ? this._config.popperConfig(defaultBsPopperConfig) : this._config.popperConfig)
};
}
- _selectMenuItem(event) {
+ _selectMenuItem({
+ key,
+ target
+ }) {
const items = SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, this._menu).filter(isVisible);
if (!items.length) {
return;
- }
+ } // if target isn't included in items (e.g. when expanding the dropdown)
+ // allow cycling to get the last item in case key equals ARROW_UP_KEY
- let index = items.indexOf(event.target); // Up
- if (event.key === ARROW_UP_KEY && index > 0) {
- index--;
- } // Down
-
-
- if (event.key === ARROW_DOWN_KEY && index < items.length - 1) {
- index++;
- } // index is -1 if the first keydown is an ArrowUp
-
-
- index = index === -1 ? 0 : index;
- items[index].focus();
+ getNextActiveElement(items, target, key === ARROW_DOWN_KEY, !items.includes(target)).focus();
} // Static
static dropdownInterface(element, config) {
- let data = Data.get(element, DATA_KEY$7);
+ const data = Dropdown.getOrCreateInstance(element, config);
- const _config = typeof config === 'object' ? config : null;
-
- if (!data) {
- data = new Dropdown(element, _config);
- }
-
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new TypeError(`No method named "${config}"`);
}
@@ -2331,11 +2326,11 @@
}
const toggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE$3);
for (let i = 0, len = toggles.length; i < len; i++) {
- const context = Data.get(toggles[i], DATA_KEY$7);
+ const context = Dropdown.getInstance(toggles[i]);
if (!context || context._config.autoClose === false) {
continue;
}
@@ -2404,21 +2399,23 @@
getToggleButton().focus();
Dropdown.clearMenus();
return;
}
- if (!isActive && (event.key === ARROW_UP_KEY || event.key === ARROW_DOWN_KEY)) {
- getToggleButton().click();
+ if (event.key === ARROW_UP_KEY || event.key === ARROW_DOWN_KEY) {
+ if (!isActive) {
+ getToggleButton().click();
+ }
+
+ Dropdown.getInstance(getToggleButton())._selectMenuItem(event);
+
return;
}
if (!isActive || event.key === SPACE_KEY) {
Dropdown.clearMenus();
- return;
}
-
- Dropdown.getInstance(getToggleButton())._selectMenuItem(event);
}
}
/**
* ------------------------------------------------------------------------
@@ -2444,100 +2441,130 @@
defineJQueryPlugin(Dropdown);
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.1): util/scrollBar.js
+ * Bootstrap (v5.0.2): 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';
- const getWidth = () => {
- // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes
- const documentWidth = document.documentElement.clientWidth;
- return Math.abs(window.innerWidth - documentWidth);
- };
+ class ScrollBarHelper {
+ constructor() {
+ this._element = document.body;
+ }
- const hide = (width = getWidth()) => {
- _disableOverFlow(); // give padding to element to balances the hidden scrollbar width
+ getWidth() {
+ // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes
+ const documentWidth = document.documentElement.clientWidth;
+ return Math.abs(window.innerWidth - documentWidth);
+ }
+ hide() {
+ const width = this.getWidth();
- _setElementAttributes('body', 'paddingRight', calculatedValue => calculatedValue + width); // trick: We adjust positive paddingRight and negative marginRight to sticky-top elements, to keep shown fullwidth
+ this._disableOverFlow(); // give padding to element to balance the hidden scrollbar width
- _setElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight', calculatedValue => calculatedValue + width);
+ this._setElementAttributes(this._element, 'paddingRight', calculatedValue => calculatedValue + width); // trick: We adjust positive paddingRight and negative marginRight to sticky-top elements to keep showing fullwidth
- _setElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight', calculatedValue => calculatedValue - width);
- };
- const _disableOverFlow = () => {
- const actualValue = document.body.style.overflow;
+ this._setElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight', calculatedValue => calculatedValue + width);
- if (actualValue) {
- Manipulator.setDataAttribute(document.body, 'overflow', actualValue);
+ this._setElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight', calculatedValue => calculatedValue - width);
}
- document.body.style.overflow = 'hidden';
- };
+ _disableOverFlow() {
+ this._saveInitialAttribute(this._element, 'overflow');
- const _setElementAttributes = (selector, styleProp, callback) => {
- const scrollbarWidth = getWidth();
- SelectorEngine.find(selector).forEach(element => {
- if (element !== document.body && window.innerWidth > element.clientWidth + scrollbarWidth) {
- return;
- }
+ this._element.style.overflow = 'hidden';
+ }
- const actualValue = element.style[styleProp];
- const calculatedValue = window.getComputedStyle(element)[styleProp];
- Manipulator.setDataAttribute(element, styleProp, actualValue);
- element.style[styleProp] = `${callback(Number.parseFloat(calculatedValue))}px`;
- });
- };
+ _setElementAttributes(selector, styleProp, callback) {
+ const scrollbarWidth = this.getWidth();
- const reset = () => {
- _resetElementAttributes('body', 'overflow');
+ const manipulationCallBack = element => {
+ if (element !== this._element && window.innerWidth > element.clientWidth + scrollbarWidth) {
+ return;
+ }
- _resetElementAttributes('body', 'paddingRight');
+ this._saveInitialAttribute(element, styleProp);
- _resetElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight');
+ const calculatedValue = window.getComputedStyle(element)[styleProp];
+ element.style[styleProp] = `${callback(Number.parseFloat(calculatedValue))}px`;
+ };
- _resetElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight');
- };
+ this._applyManipulationCallback(selector, manipulationCallBack);
+ }
- const _resetElementAttributes = (selector, styleProp) => {
- SelectorEngine.find(selector).forEach(element => {
- const value = Manipulator.getDataAttribute(element, styleProp);
+ reset() {
+ this._resetElementAttributes(this._element, 'overflow');
- if (typeof value === 'undefined') {
- element.style.removeProperty(styleProp);
+ this._resetElementAttributes(this._element, 'paddingRight');
+
+ this._resetElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight');
+
+ this._resetElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight');
+ }
+
+ _saveInitialAttribute(element, styleProp) {
+ const actualValue = element.style[styleProp];
+
+ if (actualValue) {
+ Manipulator.setDataAttribute(element, styleProp, actualValue);
+ }
+ }
+
+ _resetElementAttributes(selector, styleProp) {
+ const manipulationCallBack = element => {
+ const value = Manipulator.getDataAttribute(element, styleProp);
+
+ if (typeof value === 'undefined') {
+ element.style.removeProperty(styleProp);
+ } else {
+ Manipulator.removeDataAttribute(element, styleProp);
+ element.style[styleProp] = value;
+ }
+ };
+
+ this._applyManipulationCallback(selector, manipulationCallBack);
+ }
+
+ _applyManipulationCallback(selector, callBack) {
+ if (isElement(selector)) {
+ callBack(selector);
} else {
- Manipulator.removeDataAttribute(element, styleProp);
- element.style[styleProp] = value;
+ SelectorEngine.find(selector, this._element).forEach(callBack);
}
- });
- };
+ }
+ isOverflowing() {
+ return this.getWidth() > 0;
+ }
+
+ }
+
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.1): util/backdrop.js
+ * Bootstrap (v5.0.2): util/backdrop.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
const Default$6 = {
isVisible: true,
// if false, we use the backdrop helper without adding any element to the dom
isAnimated: false,
- rootElement: document.body,
+ rootElement: 'body',
// give the choice to place backdrop under different elements
clickCallback: null
};
const DefaultType$6 = {
isVisible: 'boolean',
isAnimated: 'boolean',
- rootElement: 'element',
+ rootElement: '(element|string)',
clickCallback: '(function|null)'
};
const NAME$7 = 'backdrop';
const CLASS_NAME_BACKDROP = 'modal-backdrop';
const CLASS_NAME_FADE$5 = 'fade';
@@ -2601,12 +2628,13 @@
}
_getConfig(config) {
config = { ...Default$6,
...(typeof config === 'object' ? config : {})
- };
- config.rootElement = config.rootElement || document.body;
+ }; // use getElement() with the default "body" to get a fresh Element on each instantiation
+
+ config.rootElement = getElement(config.rootElement);
typeCheckConfig(NAME$7, config, DefaultType$6);
return config;
}
_append() {
@@ -2627,31 +2655,24 @@
return;
}
EventHandler.off(this._element, EVENT_MOUSEDOWN);
- this._getElement().parentNode.removeChild(this._element);
+ this._element.remove();
this._isAppended = false;
}
_emulateAnimation(callback) {
- if (!this._config.isAnimated) {
- execute(callback);
- return;
- }
-
- const backdropTransitionDuration = getTransitionDurationFromElement(this._getElement());
- EventHandler.one(this._getElement(), 'transitionend', () => execute(callback));
- emulateTransitionEnd(this._getElement(), backdropTransitionDuration);
+ executeAfterTransition(callback, this._getElement(), this._config.isAnimated);
}
}
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.1): modal.js
+ * Bootstrap (v5.0.2): modal.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* ------------------------------------------------------------------------
@@ -2707,10 +2728,11 @@
this._dialog = SelectorEngine.findOne(SELECTOR_DIALOG, this._element);
this._backdrop = this._initializeBackDrop();
this._isShown = false;
this._ignoreBackdropClick = false;
this._isTransitioning = false;
+ this._scrollBar = new ScrollBarHelper();
} // Getters
static get Default() {
return Default$5;
@@ -2728,24 +2750,26 @@
show(relatedTarget) {
if (this._isShown || this._isTransitioning) {
return;
}
- if (this._isAnimated()) {
- this._isTransitioning = true;
- }
-
const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$3, {
relatedTarget
});
- if (this._isShown || showEvent.defaultPrevented) {
+ if (showEvent.defaultPrevented) {
return;
}
this._isShown = true;
- hide();
+
+ if (this._isAnimated()) {
+ this._isTransitioning = true;
+ }
+
+ this._scrollBar.hide();
+
document.body.classList.add(CLASS_NAME_OPEN);
this._adjustDialog();
this._setEscapeEvent();
@@ -2763,11 +2787,11 @@
this._showBackdrop(() => this._showElement(relatedTarget));
}
hide(event) {
- if (event) {
+ if (event && ['A', 'AREA'].includes(event.target.tagName)) {
event.preventDefault();
}
if (!this._isShown || this._isTransitioning) {
return;
@@ -2830,11 +2854,11 @@
}
_getConfig(config) {
config = { ...Default$5,
...Manipulator.getDataAttributes(this._element),
- ...config
+ ...(typeof config === 'object' ? config : {})
};
typeCheckConfig(NAME$6, config, DefaultType$5);
return config;
}
@@ -2933,11 +2957,12 @@
this._backdrop.hide(() => {
document.body.classList.remove(CLASS_NAME_OPEN);
this._resetAdjustments();
- reset();
+ this._scrollBar.reset();
+
EventHandler.trigger(this._element, EVENT_HIDDEN$3);
});
}
_showBackdrop(callback) {
@@ -2970,41 +2995,48 @@
if (hideEvent.defaultPrevented) {
return;
}
- const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
+ const {
+ classList,
+ scrollHeight,
+ style
+ } = this._element;
+ const isModalOverflowing = scrollHeight > document.documentElement.clientHeight; // return if the following background transition hasn't yet completed
+ if (!isModalOverflowing && style.overflowY === 'hidden' || classList.contains(CLASS_NAME_STATIC)) {
+ return;
+ }
+
if (!isModalOverflowing) {
- this._element.style.overflowY = 'hidden';
+ style.overflowY = 'hidden';
}
- this._element.classList.add(CLASS_NAME_STATIC);
+ classList.add(CLASS_NAME_STATIC);
- const modalTransitionDuration = getTransitionDurationFromElement(this._dialog);
- EventHandler.off(this._element, 'transitionend');
- EventHandler.one(this._element, 'transitionend', () => {
- this._element.classList.remove(CLASS_NAME_STATIC);
+ this._queueCallback(() => {
+ classList.remove(CLASS_NAME_STATIC);
if (!isModalOverflowing) {
- EventHandler.one(this._element, 'transitionend', () => {
- this._element.style.overflowY = '';
- });
- emulateTransitionEnd(this._element, modalTransitionDuration);
+ this._queueCallback(() => {
+ style.overflowY = '';
+ }, this._dialog);
}
- });
- emulateTransitionEnd(this._element, modalTransitionDuration);
+ }, this._dialog);
this._element.focus();
} // ----------------------------------------------------------------------
// the following methods are used to handle overflowing modals
// ----------------------------------------------------------------------
_adjustDialog() {
const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
- const scrollbarWidth = getWidth();
+
+ const scrollbarWidth = this._scrollBar.getWidth();
+
const isBodyOverflowing = scrollbarWidth > 0;
if (!isBodyOverflowing && isModalOverflowing && !isRTL() || isBodyOverflowing && !isModalOverflowing && isRTL()) {
this._element.style.paddingLeft = `${scrollbarWidth}px`;
}
@@ -3020,11 +3052,11 @@
} // Static
static jQueryInterface(config, relatedTarget) {
return this.each(function () {
- const data = Modal.getInstance(this) || new Modal(this, typeof config === 'object' ? config : {});
+ const data = Modal.getOrCreateInstance(this, config);
if (typeof config !== 'string') {
return;
}
@@ -3061,11 +3093,11 @@
if (isVisible(this)) {
this.focus();
}
});
});
- const data = Modal.getInstance(target) || new Modal(target);
+ const data = Modal.getOrCreateInstance(target);
data.toggle(this);
});
/**
* ------------------------------------------------------------------------
* jQuery
@@ -3075,11 +3107,11 @@
defineJQueryPlugin(Modal);
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.1): offcanvas.js
+ * Bootstrap (v5.0.2): offcanvas.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* ------------------------------------------------------------------------
@@ -3162,11 +3194,11 @@
this._element.style.visibility = 'visible';
this._backdrop.show();
if (!this._config.scroll) {
- hide();
+ new ScrollBarHelper().hide();
this._enforceFocusOnElement(this._element);
}
this._element.removeAttribute('aria-hidden');
@@ -3215,11 +3247,11 @@
this._element.removeAttribute('role');
this._element.style.visibility = 'hidden';
if (!this._config.scroll) {
- reset();
+ new ScrollBarHelper().reset();
}
EventHandler.trigger(this._element, EVENT_HIDDEN$2);
};
@@ -3273,11 +3305,11 @@
} // Static
static jQueryInterface(config) {
return this.each(function () {
- const data = Data.get(this, DATA_KEY$5) || new Offcanvas(this, typeof config === 'object' ? config : {});
+ const data = Offcanvas.getOrCreateInstance(this, config);
if (typeof config !== 'string') {
return;
}
@@ -3319,27 +3351,25 @@
if (allReadyOpen && allReadyOpen !== target) {
Offcanvas.getInstance(allReadyOpen).hide();
}
- const data = Data.get(target, DATA_KEY$5) || new Offcanvas(target);
+ const data = Offcanvas.getOrCreateInstance(target);
data.toggle(this);
});
- EventHandler.on(window, EVENT_LOAD_DATA_API$1, () => {
- SelectorEngine.find(OPEN_SELECTOR).forEach(el => (Data.get(el, DATA_KEY$5) || new Offcanvas(el)).show());
- });
+ EventHandler.on(window, EVENT_LOAD_DATA_API$1, () => SelectorEngine.find(OPEN_SELECTOR).forEach(el => Offcanvas.getOrCreateInstance(el).show()));
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
*/
defineJQueryPlugin(Offcanvas);
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.1): util/sanitizer.js
+ * Bootstrap (v5.0.2): 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;
@@ -3430,11 +3460,11 @@
for (let i = 0, len = elements.length; i < len; i++) {
const el = elements[i];
const elName = el.nodeName.toLowerCase();
if (!allowlistKeys.includes(elName)) {
- el.parentNode.removeChild(el);
+ el.remove();
continue;
}
const attributeList = [].concat(...el.attributes);
const allowedAttributes = [].concat(allowList['*'] || [], allowList[elName] || []);
@@ -3448,11 +3478,11 @@
return createdDocument.body.innerHTML;
}
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.1): tooltip.js
+ * Bootstrap (v5.0.2): tooltip.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* ------------------------------------------------------------------------
@@ -3617,12 +3647,12 @@
dispose() {
clearTimeout(this._timeout);
EventHandler.off(this._element.closest(`.${CLASS_NAME_MODAL}`), 'hide.bs.modal', this._hideModalHandler);
- if (this.tip && this.tip.parentNode) {
- this.tip.parentNode.removeChild(this.tip);
+ if (this.tip) {
+ this.tip.remove();
}
if (this._popper) {
this._popper.destroy();
}
@@ -3723,12 +3753,12 @@
const complete = () => {
if (this._isWithActiveTrigger()) {
return;
}
- if (this._hoverState !== HOVER_STATE_SHOW && tip.parentNode) {
- tip.parentNode.removeChild(tip);
+ if (this._hoverState !== HOVER_STATE_SHOW) {
+ tip.remove();
}
this._cleanTipClass();
this._element.removeAttribute('aria-describedby');
@@ -4111,22 +4141,12 @@
} // Static
static jQueryInterface(config) {
return this.each(function () {
- let data = Data.get(this, DATA_KEY$4);
+ const data = Tooltip.getOrCreateInstance(this, config);
- const _config = typeof config === 'object' && config;
-
- if (!data && /dispose|hide/.test(config)) {
- return;
- }
-
- if (!data) {
- data = new Tooltip(this, _config);
- }
-
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new TypeError(`No method named "${config}"`);
}
@@ -4146,11 +4166,11 @@
defineJQueryPlugin(Tooltip);
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.1): popover.js
+ * Bootstrap (v5.0.2): popover.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* ------------------------------------------------------------------------
@@ -4216,10 +4236,28 @@
isWithContent() {
return this.getTitle() || this._getContent();
}
+ getTipElement() {
+ if (this.tip) {
+ return this.tip;
+ }
+
+ this.tip = super.getTipElement();
+
+ if (!this.getTitle()) {
+ SelectorEngine.findOne(SELECTOR_TITLE, this.tip).remove();
+ }
+
+ if (!this._getContent()) {
+ SelectorEngine.findOne(SELECTOR_CONTENT, this.tip).remove();
+ }
+
+ return this.tip;
+ }
+
setContent() {
const tip = this.getTipElement(); // we use append for html objects to maintain js events
this.setElementContent(SelectorEngine.findOne(SELECTOR_TITLE, tip), this.getTitle());
@@ -4252,23 +4290,12 @@
} // Static
static jQueryInterface(config) {
return this.each(function () {
- let data = Data.get(this, DATA_KEY$3);
+ const data = Popover.getOrCreateInstance(this, config);
- const _config = typeof config === 'object' ? config : null;
-
- if (!data && /dispose|hide/.test(config)) {
- return;
- }
-
- if (!data) {
- data = new Popover(this, _config);
- Data.set(this, DATA_KEY$3, data);
- }
-
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new TypeError(`No method named "${config}"`);
}
@@ -4288,11 +4315,11 @@
defineJQueryPlugin(Popover);
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.1): scrollspy.js
+ * Bootstrap (v5.0.2): scrollspy.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* ------------------------------------------------------------------------
@@ -4503,11 +4530,11 @@
} // Static
static jQueryInterface(config) {
return this.each(function () {
- const data = ScrollSpy.getInstance(this) || new ScrollSpy(this, typeof config === 'object' ? config : {});
+ const data = ScrollSpy.getOrCreateInstance(this, config);
if (typeof config !== 'string') {
return;
}
@@ -4539,11 +4566,11 @@
defineJQueryPlugin(ScrollSpy);
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.1): tab.js
+ * Bootstrap (v5.0.2): tab.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* ------------------------------------------------------------------------
@@ -4694,11 +4721,11 @@
} // Static
static jQueryInterface(config) {
return this.each(function () {
- const data = Data.get(this, DATA_KEY$1) || new Tab(this);
+ const data = Tab.getOrCreateInstance(this);
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new TypeError(`No method named "${config}"`);
}
@@ -4723,11 +4750,11 @@
if (isDisabled(this)) {
return;
}
- const data = Data.get(this, DATA_KEY$1) || new Tab(this);
+ const data = Tab.getOrCreateInstance(this);
data.show();
});
/**
* ------------------------------------------------------------------------
* jQuery
@@ -4737,11 +4764,11 @@
defineJQueryPlugin(Tab);
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.1): toast.js
+ * Bootstrap (v5.0.2): toast.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* ------------------------------------------------------------------------
@@ -4937,18 +4964,12 @@
} // Static
static jQueryInterface(config) {
return this.each(function () {
- let data = Data.get(this, DATA_KEY);
+ const data = Toast.getOrCreateInstance(this, config);
- const _config = typeof config === 'object' && config;
-
- if (!data) {
- data = new Toast(this, _config);
- }
-
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new TypeError(`No method named "${config}"`);
}
@@ -4968,10 +4989,10 @@
defineJQueryPlugin(Toast);
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.1): index.umd.js
+ * Bootstrap (v5.0.2): index.umd.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
var index_umd = {
Alert,