diff options
| author | XhmikosR <[email protected]> | 2021-07-29 09:14:40 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-07-29 09:14:40 +0300 |
| commit | ef5336373fc2431b3d1d37cde85cd262210a1dc6 (patch) | |
| tree | e325fb4c5532b464d05780c731d0f118f2a88d7f /js/dist/base-component.js | |
| parent | 62edf07d7491684fe67a9c1e9439ed2bd10ca741 (diff) | |
| parent | c6c0bbb0b67fe89b55740a63fd10d4ad79044970 (diff) | |
| download | bootstrap-main-fod-simpler-table-structure.tar.xz bootstrap-main-fod-simpler-table-structure.zip | |
Merge branch 'main' into main-fod-simpler-table-structuremain-fod-simpler-table-structure
Diffstat (limited to 'js/dist/base-component.js')
| -rw-r--r-- | js/dist/base-component.js | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/js/dist/base-component.js b/js/dist/base-component.js index 8108186a1..18f7f25ea 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; } |
