mirror of
https://github.com/twbs/bootstrap.git
synced 2025-03-01 01:54:24 +01:00
Merge dropdownInterface
to jQueryInterface
This commit is contained in:
parent
d3c6f25fd0
commit
3533e2d637
@ -371,21 +371,19 @@ class Dropdown extends BaseComponent {
|
|||||||
|
|
||||||
// Static
|
// Static
|
||||||
|
|
||||||
static dropdownInterface(element, config) {
|
static jQueryInterface(config) {
|
||||||
const data = Dropdown.getOrCreateInstance(element, config)
|
return this.each(function () {
|
||||||
|
const data = Dropdown.getOrCreateInstance(this, config)
|
||||||
|
|
||||||
|
if (typeof config !== 'string') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof config === 'string') {
|
|
||||||
if (typeof data[config] === 'undefined') {
|
if (typeof data[config] === 'undefined') {
|
||||||
throw new TypeError(`No method named "${config}"`)
|
throw new TypeError(`No method named "${config}"`)
|
||||||
}
|
}
|
||||||
|
|
||||||
data[config]()
|
data[config]()
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static jQueryInterface(config) {
|
|
||||||
return this.each(function () {
|
|
||||||
Dropdown.dropdownInterface(this, config)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -503,7 +501,7 @@ EventHandler.on(document, EVENT_CLICK_DATA_API, Dropdown.clearMenus)
|
|||||||
EventHandler.on(document, EVENT_KEYUP_DATA_API, Dropdown.clearMenus)
|
EventHandler.on(document, EVENT_KEYUP_DATA_API, Dropdown.clearMenus)
|
||||||
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
|
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
Dropdown.dropdownInterface(this)
|
Dropdown.getOrCreateInstance(this)
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user