From 3323150dc2aed4f3c896258afa6941df6d234b18 Mon Sep 17 00:00:00 2001 From: GeoSot Date: Thu, 10 Jun 2021 03:00:40 +0300 Subject: [PATCH] transfer `interface` inside `jQueryInterface` --- js/src/collapse.js | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/js/src/collapse.js b/js/src/collapse.js index e9796666e2d3..a85bf362c683 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -148,7 +148,7 @@ class Collapse extends BaseComponent { actives.forEach(elemActive => { if (this._element !== elemActive) { - Collapse.collapseInterface(elemActive, 'hide') + Collapse.getOrCreateInstance(elemActive, { toggle: false }).hide() } if (!activesData) { @@ -280,26 +280,22 @@ class Collapse extends BaseComponent { // Static - static collapseInterface(element, config) { - const _config = {} - if (typeof config === 'string' && /show|hide/.test(config)) { - _config.toggle = false - } - - const data = Collapse.getOrCreateInstance(element, _config) - - if (typeof config === 'string') { - if (typeof data[config] === 'undefined') { - throw new TypeError(`No method named "${config}"`) + static jQueryInterface(config) { + return this.each(function () { + const _config = {} + if (typeof config === 'string' && /show|hide/.test(config)) { + _config.toggle = false } - data[config]() - } - } + const data = Collapse.getOrCreateInstance(this, _config) - static jQueryInterface(config) { - return this.each(function () { - Collapse.collapseInterface(this, config) + if (typeof config === 'string') { + if (typeof data[config] === 'undefined') { + throw new TypeError(`No method named "${config}"`) + } + + data[config]() + } }) } }