1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-09-27 22:09:04 +02:00

Refactor components to use a utility function to define jQuery plugins (#32285)

* refactor: use an utility function to define jQuery plugins

* test: add spec for defineJQueryPlugin utility function

* Update .bundlewatch.config.json

Co-authored-by: XhmikosR <xhmikosr@gmail.com>
This commit is contained in:
alpadev
2020-12-08 07:16:50 +01:00
committed by GitHub
parent 07b60d2c3e
commit 85208ae557
14 changed files with 67 additions and 167 deletions

View File

@@ -188,6 +188,22 @@ const onDOMContentLoaded = callback => {
const isRTL = document.documentElement.dir === 'rtl'
const defineJQueryPlugin = (name, plugin) => {
onDOMContentLoaded(() => {
const $ = getjQuery()
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[name]
$.fn[name] = plugin.jQueryInterface
$.fn[name].Constructor = plugin
$.fn[name].noConflict = () => {
$.fn[name] = JQUERY_NO_CONFLICT
return plugin.jQueryInterface
}
}
})
}
export {
TRANSITION_END,
getUID,
@@ -204,5 +220,6 @@ export {
reflow,
getjQuery,
onDOMContentLoaded,
isRTL
isRTL,
defineJQueryPlugin
}