Skip to content

Commit

Permalink
transfer interface inside jQueryInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
GeoSot committed Jul 6, 2021
1 parent ef76ac2 commit 3323150
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions js/src/collapse.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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]()
}
})
}
}
Expand Down

0 comments on commit 3323150

Please sign in to comment.