diff options
author | GeoSot <geo.sotis@gmail.com> | 2021-06-10 03:00:40 +0300 |
---|---|---|
committer | XhmikosR <xhmikosr@gmail.com> | 2021-07-29 16:30:02 +0300 |
commit | 2bf32ad18017f85380eb6daed3a314b88e1e851a (patch) | |
tree | 7b319bf4432b576ae39407f7da463a7da2824c90 /js/src/collapse.js | |
parent | e5b606d2422334a760a7e1d574ba4ee6b4b85b0d (diff) |
transfer `interface` inside `jQueryInterface`
Diffstat (limited to 'js/src/collapse.js')
-rw-r--r-- | js/src/collapse.js | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/js/src/collapse.js b/js/src/collapse.js index b238738d94..7c66b2eca0 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -147,7 +147,7 @@ class Collapse extends BaseComponent { actives.forEach(elemActive => { if (container !== elemActive) { - Collapse.collapseInterface(elemActive, 'hide') + Collapse.getOrCreateInstance(elemActive, { toggle: false }).hide() } if (!activesData) { @@ -282,26 +282,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]() + } }) } } |