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:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user