diff options
author | Sascha <mail@sascha.dev> | 2020-11-01 16:32:36 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-01 16:32:36 +0300 |
commit | c21506d499c682ea5e31107ce264b224c4bb644d (patch) | |
tree | c2f0ec5f54fb64bde3db98d090485d88b51e0960 /js/src/dropdown.js | |
parent | 3a5f9f5cf004ff02eca0b1680b461b79dd61d980 (diff) |
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 <xhmikosr@gmail.com>
Diffstat (limited to 'js/src/dropdown.js')
-rw-r--r-- | js/src/dropdown.js | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/js/src/dropdown.js b/js/src/dropdown.js index 28d8b72992..46311ee8ad 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -7,6 +7,7 @@ import { getjQuery, + onDOMContentLoaded, getElementFromSelector, isElement, isVisible, @@ -512,23 +513,25 @@ EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function ( }) EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_FORM_CHILD, e => e.stopPropagation()) -const $ = getjQuery() - /** * ------------------------------------------------------------------------ * jQuery * ------------------------------------------------------------------------ * add .dropdown to jQuery only if jQuery is present */ -/* istanbul ignore if */ -if ($) { - const JQUERY_NO_CONFLICT = $.fn[NAME] - $.fn[NAME] = Dropdown.jQueryInterface - $.fn[NAME].Constructor = Dropdown - $.fn[NAME].noConflict = () => { - $.fn[NAME] = JQUERY_NO_CONFLICT - return Dropdown.jQueryInterface + +onDOMContentLoaded(() => { + const $ = getjQuery() + /* istanbul ignore if */ + if ($) { + const JQUERY_NO_CONFLICT = $.fn[NAME] + $.fn[NAME] = Dropdown.jQueryInterface + $.fn[NAME].Constructor = Dropdown + $.fn[NAME].noConflict = () => { + $.fn[NAME] = JQUERY_NO_CONFLICT + return Dropdown.jQueryInterface + } } -} +}) export default Dropdown |