diff options
| author | Sascha <[email protected]> | 2020-11-01 14:32:36 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-11-01 15:32:36 +0200 |
| commit | c21506d499c682ea5e31107ce264b224c4bb644d (patch) | |
| tree | c2f0ec5f54fb64bde3db98d090485d88b51e0960 /js/src/tab.js | |
| parent | 3a5f9f5cf004ff02eca0b1680b461b79dd61d980 (diff) | |
| download | bootstrap-c21506d499c682ea5e31107ce264b224c4bb644d.tar.xz bootstrap-c21506d499c682ea5e31107ce264b224c4bb644d.zip | |
Fix TypeError when Bootstrap is included in `head` (#32024)
* extend jquery after domContentLoaded event is fired
* add unittest for util onDOMContentLoaded
* wait for trigger jquery event after domContentLoaded
* remove domcontentready from eventHandler
* move istanbul ignore statements to correct line
Co-authored-by: XhmikosR <[email protected]>
Diffstat (limited to 'js/src/tab.js')
| -rw-r--r-- | js/src/tab.js | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/js/src/tab.js b/js/src/tab.js index 76895b8dd..af0dfc97a 100644 --- a/js/src/tab.js +++ b/js/src/tab.js @@ -7,6 +7,7 @@ import { getjQuery, + onDOMContentLoaded, TRANSITION_END, emulateTransitionEnd, getElementFromSelector, @@ -235,23 +236,25 @@ EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function ( data.show() }) -const $ = getjQuery() - /** * ------------------------------------------------------------------------ * jQuery * ------------------------------------------------------------------------ * add .tab to jQuery only if jQuery is present */ -/* istanbul ignore if */ -if ($) { - const JQUERY_NO_CONFLICT = $.fn[NAME] - $.fn[NAME] = Tab.jQueryInterface - $.fn[NAME].Constructor = Tab - $.fn[NAME].noConflict = () => { - $.fn[NAME] = JQUERY_NO_CONFLICT - return Tab.jQueryInterface + +onDOMContentLoaded(() => { + const $ = getjQuery() + /* istanbul ignore if */ + if ($) { + const JQUERY_NO_CONFLICT = $.fn[NAME] + $.fn[NAME] = Tab.jQueryInterface + $.fn[NAME].Constructor = Tab + $.fn[NAME].noConflict = () => { + $.fn[NAME] = JQUERY_NO_CONFLICT + return Tab.jQueryInterface + } } -} +}) export default Tab |
