Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXhmikosR <xhmikosr@gmail.com>2021-06-22 21:29:16 +0300
committerGitHub <noreply@github.com>2021-06-22 21:29:16 +0300
commit688bce4fa695cc360a0d084e34f029b0c192b223 (patch)
treedcda8a139b0225f23df2c3d3811afdefbc6d5af0 /dist/js/bootstrap.esm.js
parent16d5041a76748580bae47ce168ba579daae9725b (diff)
Release v5.0.2 (#34276)v5.0.2
* Bump version to v5.0.2. * Dist
Diffstat (limited to 'dist/js/bootstrap.esm.js')
-rw-r--r--dist/js/bootstrap.esm.js641
1 files changed, 331 insertions, 310 deletions
diff --git a/dist/js/bootstrap.esm.js b/dist/js/bootstrap.esm.js
index 5f180da33c..92ead78915 100644
--- a/dist/js/bootstrap.esm.js
+++ b/dist/js/bootstrap.esm.js
@@ -1,5 +1,5 @@
/*!
- * 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)
*/
@@ -7,7 +7,7 @@ import * as Popper from '@popperjs/core';
/**
* --------------------------------------------------------------------------
- * 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)
* --------------------------------------------------------------------------
*/
@@ -78,7 +78,7 @@ const SelectorEngine = {
/**
* --------------------------------------------------------------------------
- * 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)
* --------------------------------------------------------------------------
*/
@@ -200,24 +200,6 @@ const getElement = obj => {
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];
@@ -231,17 +213,11 @@ const typeCheckConfig = (componentName, config, configTypes) => {
};
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 => {
@@ -299,9 +275,18 @@ const getjQuery = () => {
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();
}
@@ -334,63 +319,66 @@ const execute = callback => {
}
};
-/**
- * --------------------------------------------------------------------------
- * Bootstrap (v5.0.1): 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 executeAfterTransition = (callback, transitionElement, waitForTransition = true) => {
+ if (!waitForTransition) {
+ execute(callback);
+ return;
+ }
- 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
+ const durationPadding = 5;
+ const emulatedDuration = getTransitionDurationFromElement(transitionElement) + durationPadding;
+ let called = false;
- 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)
* --------------------------------------------------------------------------
*/
@@ -679,17 +667,71 @@ const EventHandler = {
/**
* --------------------------------------------------------------------------
- * 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 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
-const VERSION = '5.0.1';
+ 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) {
@@ -712,14 +754,7 @@ class BaseComponent {
}
_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 */
@@ -728,6 +763,10 @@ class BaseComponent {
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;
}
@@ -748,7 +787,7 @@ class BaseComponent {
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.1): alert.js
+ * Bootstrap (v5.0.2): alert.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
@@ -811,21 +850,14 @@ class Alert extends BaseComponent {
}
_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);
-
- if (!data) {
- data = new Alert(this);
- }
+ const data = Alert.getOrCreateInstance(this);
if (config === 'close') {
data[config](this);
@@ -863,7 +895,7 @@ 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)
* --------------------------------------------------------------------------
*/
@@ -901,11 +933,7 @@ class Button extends BaseComponent {
static jQueryInterface(config) {
return this.each(function () {
- let data = Data.get(this, DATA_KEY$a);
-
- if (!data) {
- data = new Button(this);
- }
+ const data = Button.getOrCreateInstance(this);
if (config === 'toggle') {
data[config]();
@@ -924,12 +952,7 @@ class Button extends BaseComponent {
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();
});
/**
@@ -943,7 +966,7 @@ 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)
* --------------------------------------------------------------------------
*/
@@ -1017,7 +1040,7 @@ const Manipulator = {
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.1): carousel.js
+ * Bootstrap (v5.0.2): carousel.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
@@ -1056,6 +1079,10 @@ 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}`;
@@ -1124,9 +1151,7 @@ class Carousel extends BaseComponent {
next() {
- if (!this._isSliding) {
- this._slide(ORDER_NEXT);
- }
+ this._slide(ORDER_NEXT);
}
nextWhenVisible() {
@@ -1138,9 +1163,7 @@ class Carousel extends BaseComponent {
}
prev() {
- if (!this._isSliding) {
- this._slide(ORDER_PREV);
- }
+ this._slide(ORDER_PREV);
}
pause(event) {
@@ -1202,7 +1225,8 @@ class Carousel extends BaseComponent {
_getConfig(config) {
config = { ...Default$9,
- ...config
+ ...Manipulator.getDataAttributes(this._element),
+ ...(typeof config === 'object' ? config : {})
};
typeCheckConfig(NAME$a, config, DefaultType$9);
return config;
@@ -1300,14 +1324,12 @@ class Carousel extends BaseComponent {
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);
}
}
@@ -1318,20 +1340,7 @@ class Carousel extends BaseComponent {
_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) {
@@ -1404,6 +1413,10 @@ class Carousel extends BaseComponent {
return;
}
+ if (this._isSliding) {
+ return;
+ }
+
const slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
if (slideEvent.defaultPrevented) {
@@ -1487,10 +1500,10 @@ class Carousel extends BaseComponent {
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,
@@ -1500,10 +1513,6 @@ class Carousel extends BaseComponent {
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') {
@@ -1543,7 +1552,7 @@ class Carousel extends BaseComponent {
Carousel.carouselInterface(target, config);
if (slideIndex) {
- Data.get(target, DATA_KEY$9).to(slideIndex);
+ Carousel.getInstance(target).to(slideIndex);
}
event.preventDefault();
@@ -1562,7 +1571,7 @@ 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]));
}
});
/**
@@ -1576,7 +1585,7 @@ 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)
* --------------------------------------------------------------------------
*/
@@ -1692,7 +1701,7 @@ class Collapse extends BaseComponent {
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;
@@ -1855,7 +1864,7 @@ class Collapse extends BaseComponent {
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 : {})
@@ -1902,7 +1911,7 @@ EventHandler.on(document, EVENT_CLICK_DATA_API$4, SELECTOR_DATA_TOGGLE$4, functi
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) {
@@ -1931,7 +1940,7 @@ 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)
* --------------------------------------------------------------------------
*/
@@ -2251,38 +2260,24 @@ class Dropdown extends BaseComponent {
};
}
- _selectMenuItem(event) {
+ _selectMenuItem({
+ key,
+ target
+ }) {
const items = SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, this._menu).filter(isVisible);
if (!items.length) {
return;
- }
-
- let index = items.indexOf(event.target); // Up
-
- if (event.key === ARROW_UP_KEY && index > 0) {
- index--;
- } // Down
+ } // 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
- 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 _config = typeof config === 'object' ? config : null;
-
- if (!data) {
- data = new Dropdown(element, _config);
- }
+ const data = Dropdown.getOrCreateInstance(element, config);
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
@@ -2307,7 +2302,7 @@ class Dropdown extends BaseComponent {
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;
@@ -2380,17 +2375,19 @@ class Dropdown extends BaseComponent {
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);
}
}
@@ -2420,81 +2417,111 @@ 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 manipulationCallBack = element => {
+ if (element !== this._element && window.innerWidth > element.clientWidth + scrollbarWidth) {
+ return;
+ }
-const reset = () => {
- _resetElementAttributes('body', 'overflow');
+ this._saveInitialAttribute(element, styleProp);
- _resetElementAttributes('body', 'paddingRight');
+ const calculatedValue = window.getComputedStyle(element)[styleProp];
+ element.style[styleProp] = `${callback(Number.parseFloat(calculatedValue))}px`;
+ };
- _resetElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight');
+ this._applyManipulationCallback(selector, manipulationCallBack);
+ }
- _resetElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight');
-};
+ reset() {
+ this._resetElementAttributes(this._element, 'overflow');
+
+ 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;
+ }
+ };
-const _resetElementAttributes = (selector, styleProp) => {
- SelectorEngine.find(selector).forEach(element => {
- const value = Manipulator.getDataAttribute(element, styleProp);
+ this._applyManipulationCallback(selector, manipulationCallBack);
+ }
- if (typeof value === 'undefined') {
- element.style.removeProperty(styleProp);
+ _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)
* --------------------------------------------------------------------------
*/
@@ -2502,14 +2529,14 @@ 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';
@@ -2577,8 +2604,9 @@ class Backdrop {
_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;
}
@@ -2603,27 +2631,20 @@ class Backdrop {
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)
* --------------------------------------------------------------------------
*/
@@ -2683,6 +2704,7 @@ class Modal extends BaseComponent {
this._isShown = false;
this._ignoreBackdropClick = false;
this._isTransitioning = false;
+ this._scrollBar = new ScrollBarHelper();
} // Getters
@@ -2704,20 +2726,22 @@ class Modal extends BaseComponent {
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();
@@ -2739,7 +2763,7 @@ class Modal extends BaseComponent {
}
hide(event) {
- if (event) {
+ if (event && ['A', 'AREA'].includes(event.target.tagName)) {
event.preventDefault();
}
@@ -2806,7 +2830,7 @@ class Modal extends BaseComponent {
_getConfig(config) {
config = { ...Default$5,
...Manipulator.getDataAttributes(this._element),
- ...config
+ ...(typeof config === 'object' ? config : {})
};
typeCheckConfig(NAME$6, config, DefaultType$5);
return config;
@@ -2909,7 +2933,8 @@ class Modal extends BaseComponent {
this._resetAdjustments();
- reset();
+ this._scrollBar.reset();
+
EventHandler.trigger(this._element, EVENT_HIDDEN$3);
});
}
@@ -2946,27 +2971,32 @@ class Modal extends BaseComponent {
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();
} // ----------------------------------------------------------------------
@@ -2976,7 +3006,9 @@ class Modal extends BaseComponent {
_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()) {
@@ -2996,7 +3028,7 @@ class Modal extends BaseComponent {
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;
@@ -3037,7 +3069,7 @@ EventHandler.on(document, EVENT_CLICK_DATA_API$2, SELECTOR_DATA_TOGGLE$2, functi
}
});
});
- const data = Modal.getInstance(target) || new Modal(target);
+ const data = Modal.getOrCreateInstance(target);
data.toggle(this);
});
/**
@@ -3051,7 +3083,7 @@ 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)
* --------------------------------------------------------------------------
*/
@@ -3138,7 +3170,7 @@ class Offcanvas extends BaseComponent {
this._backdrop.show();
if (!this._config.scroll) {
- hide();
+ new ScrollBarHelper().hide();
this._enforceFocusOnElement(this._element);
}
@@ -3191,7 +3223,7 @@ class Offcanvas extends BaseComponent {
this._element.style.visibility = 'hidden';
if (!this._config.scroll) {
- reset();
+ new ScrollBarHelper().reset();
}
EventHandler.trigger(this._element, EVENT_HIDDEN$2);
@@ -3249,7 +3281,7 @@ class Offcanvas extends BaseComponent {
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;
@@ -3295,12 +3327,10 @@ EventHandler.on(document, EVENT_CLICK_DATA_API$1, SELECTOR_DATA_TOGGLE$1, functi
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
@@ -3311,7 +3341,7 @@ 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)
* --------------------------------------------------------------------------
*/
@@ -3406,7 +3436,7 @@ function sanitizeHtml(unsafeHtml, allowList, sanitizeFn) {
const elName = el.nodeName.toLowerCase();
if (!allowlistKeys.includes(elName)) {
- el.parentNode.removeChild(el);
+ el.remove();
continue;
}
@@ -3424,7 +3454,7 @@ function sanitizeHtml(unsafeHtml, allowList, sanitizeFn) {
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.1): tooltip.js
+ * Bootstrap (v5.0.2): tooltip.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
@@ -3593,8 +3623,8 @@ class Tooltip extends BaseComponent {
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) {
@@ -3699,8 +3729,8 @@ class Tooltip extends BaseComponent {
return;
}
- if (this._hoverState !== HOVER_STATE_SHOW && tip.parentNode) {
- tip.parentNode.removeChild(tip);
+ if (this._hoverState !== HOVER_STATE_SHOW) {
+ tip.remove();
}
this._cleanTipClass();
@@ -4087,17 +4117,7 @@ class Tooltip extends BaseComponent {
static jQueryInterface(config) {
return this.each(function () {
- let data = Data.get(this, DATA_KEY$4);
-
- const _config = typeof config === 'object' && config;
-
- if (!data && /dispose|hide/.test(config)) {
- return;
- }
-
- if (!data) {
- data = new Tooltip(this, _config);
- }
+ const data = Tooltip.getOrCreateInstance(this, config);
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
@@ -4122,7 +4142,7 @@ 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)
* --------------------------------------------------------------------------
*/
@@ -4192,6 +4212,24 @@ class Popover extends Tooltip {
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
@@ -4228,18 +4266,7 @@ class Popover extends Tooltip {
static jQueryInterface(config) {
return this.each(function () {
- let data = Data.get(this, DATA_KEY$3);
-
- 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);
- }
+ const data = Popover.getOrCreateInstance(this, config);
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
@@ -4264,7 +4291,7 @@ 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)
* --------------------------------------------------------------------------
*/
@@ -4479,7 +4506,7 @@ class ScrollSpy extends BaseComponent {
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;
@@ -4515,7 +4542,7 @@ 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)
* --------------------------------------------------------------------------
*/
@@ -4670,7 +4697,7 @@ class Tab extends BaseComponent {
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') {
@@ -4699,7 +4726,7 @@ EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (
return;
}
- const data = Data.get(this, DATA_KEY$1) || new Tab(this);
+ const data = Tab.getOrCreateInstance(this);
data.show();
});
/**
@@ -4713,7 +4740,7 @@ 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)
* --------------------------------------------------------------------------
*/
@@ -4913,13 +4940,7 @@ class Toast extends BaseComponent {
static jQueryInterface(config) {
return this.each(function () {
- let data = Data.get(this, DATA_KEY);
-
- const _config = typeof config === 'object' && config;
-
- if (!data) {
- data = new Toast(this, _config);
- }
+ const data = Toast.getOrCreateInstance(this, config);
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {