Skip to content

Commit

Permalink
Optimize jQueryInterface in Collapse (twbs#35689)
Browse files Browse the repository at this point in the history
extracts config initialization from cycle
  • Loading branch information
WinterSilence authored Feb 7, 2022
1 parent 77e02a0 commit a805330
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions js/src/collapse.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,12 @@ class Collapse extends BaseComponent {

// Static
static jQueryInterface(config) {
return this.each(function () {
const _config = {}
if (typeof config === 'string' && /show|hide/.test(config)) {
_config.toggle = false
}
const _config = {}
if (typeof config === 'string' && /show|hide/.test(config)) {
_config.toggle = false
}

return this.each(function () {
const data = Collapse.getOrCreateInstance(this, _config)

if (typeof config === 'string') {
Expand Down

0 comments on commit a805330

Please sign in to comment.