0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-01-30 22:52:24 +01:00

Optimize jQueryInterface in Collapse (#35689)

extracts config initialization from cycle
This commit is contained in:
Anton 2022-02-07 11:50:26 +03:00 committed by GitHub
parent 77e02a07c7
commit a805330f63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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') {