Skip to content

Commit

Permalink
revert jQueryInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
GeoSot committed Apr 5, 2021
1 parent 9b2cbee commit bc6dfdf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
15 changes: 13 additions & 2 deletions js/src/scrollspy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import {
basicJQueryInterface,
defineJQueryPlugin,
getSelectorFromElement,
getUID,
Expand Down Expand Up @@ -278,7 +277,19 @@ class ScrollSpy extends BaseComponent {
// Static

static jQueryInterface(config) {
return basicJQueryInterface(this, ScrollSpy, config)
return this.each(function () {
const data = ScrollSpy.getInstance(this) || new ScrollSpy(this, typeof config === 'object' ? config : {})

if (typeof config !== 'string') {
return
}

if (typeof data[config] === 'undefined') {
throw new TypeError(`No method named "${config}"`)
}

data[config]()
})
}
}

Expand Down
19 changes: 0 additions & 19 deletions js/src/util/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import Data from '../dom/data'

/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta3): util/index.js
Expand Down Expand Up @@ -232,22 +230,6 @@ const defineJQueryPlugin = (name, plugin) => {
})
}

const basicJQueryInterface = (jq, Plugin, config) => {
return jq.each(function () {
const data = Data.get(this, Plugin.DATA_KEY) || new Plugin(this, typeof config === 'object' ? config : {})

if (typeof config !== 'string') {
return
}

if (typeof data[config] === 'undefined') {
throw new TypeError(`No method named "${config}"`)
}

data[config]()
})
}

export {
getUID,
getSelectorFromElement,
Expand All @@ -265,6 +247,5 @@ export {
getjQuery,
onDOMContentLoaded,
isRTL,
basicJQueryInterface,
defineJQueryPlugin
}

0 comments on commit bc6dfdf

Please sign in to comment.