diff --git a/js/src/scrollspy.js b/js/src/scrollspy.js index c85528ed9f7d..4e830b530b14 100644 --- a/js/src/scrollspy.js +++ b/js/src/scrollspy.js @@ -6,7 +6,6 @@ */ import { - basicJQueryInterface, defineJQueryPlugin, getSelectorFromElement, getUID, @@ -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]() + }) } } diff --git a/js/src/util/index.js b/js/src/util/index.js index 8802a0b8e04a..cc35d8a37c4c 100644 --- a/js/src/util/index.js +++ b/js/src/util/index.js @@ -1,5 +1,3 @@ -import Data from '../dom/data' - /** * -------------------------------------------------------------------------- * Bootstrap (v5.0.0-beta3): util/index.js @@ -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, @@ -265,6 +247,5 @@ export { getjQuery, onDOMContentLoaded, isRTL, - basicJQueryInterface, defineJQueryPlugin }