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:
Diffstat (limited to 'js/dist/base-component.js')
-rw-r--r--js/dist/base-component.js59
1 files changed, 34 insertions, 25 deletions
diff --git a/js/dist/base-component.js b/js/dist/base-component.js
index 8108186a1e..18f7f25ea6 100644
--- a/js/dist/base-component.js
+++ b/js/dist/base-component.js
@@ -1,5 +1,5 @@
/*!
- * Bootstrap base-component.js v5.0.1 (https://getbootstrap.com/)
+ * Bootstrap base-component.js v5.0.2 (https://getbootstrap.com/)
* Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
@@ -70,33 +70,45 @@
return null;
};
- const emulateTransitionEnd = (element, duration) => {
- let called = false;
+ const execute = callback => {
+ if (typeof callback === 'function') {
+ callback();
+ }
+ };
+
+ const executeAfterTransition = (callback, transitionElement, waitForTransition = true) => {
+ if (!waitForTransition) {
+ execute(callback);
+ return;
+ }
+
const durationPadding = 5;
- const emulatedDuration = duration + durationPadding;
+ const emulatedDuration = getTransitionDurationFromElement(transitionElement) + durationPadding;
+ let called = false;
+
+ const handler = ({
+ target
+ }) => {
+ if (target !== transitionElement) {
+ return;
+ }
- function listener() {
called = true;
- element.removeEventListener(TRANSITION_END, listener);
- }
+ transitionElement.removeEventListener(TRANSITION_END, handler);
+ execute(callback);
+ };
- element.addEventListener(TRANSITION_END, listener);
+ transitionElement.addEventListener(TRANSITION_END, handler);
setTimeout(() => {
if (!called) {
- triggerTransitionEnd(element);
+ triggerTransitionEnd(transitionElement);
}
}, emulatedDuration);
};
- const execute = callback => {
- if (typeof callback === 'function') {
- callback();
- }
- };
-
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.1): base-component.js
+ * Bootstrap (v5.0.2): base-component.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
@@ -106,7 +118,7 @@
* ------------------------------------------------------------------------
*/
- const VERSION = '5.0.1';
+ const VERSION = '5.0.2';
class BaseComponent {
constructor(element) {
@@ -129,14 +141,7 @@
}
_queueCallback(callback, element, isAnimated = true) {
- if (!isAnimated) {
- execute(callback);
- return;
- }
-
- const transitionDuration = getTransitionDurationFromElement(element);
- EventHandler__default['default'].one(element, 'transitionend', () => execute(callback));
- emulateTransitionEnd(element, transitionDuration);
+ executeAfterTransition(callback, element, isAnimated);
}
/** Static */
@@ -145,6 +150,10 @@
return Data__default['default'].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;
}