mirror of
https://github.com/twbs/bootstrap.git
synced 2025-10-02 16:28:26 +02:00
Add getOrCreateInstance
method in base-component (#33276)
Co-authored-by: Rohit Sharma <rohit2sharma95@gmail.com> Co-authored-by: XhmikosR <xhmikosr@gmail.com>
This commit is contained in:
@@ -19,7 +19,6 @@ import {
|
||||
getNextActiveElement,
|
||||
typeCheckConfig
|
||||
} from './util/index'
|
||||
import Data from './dom/data'
|
||||
import EventHandler from './dom/event-handler'
|
||||
import Manipulator from './dom/manipulator'
|
||||
import SelectorEngine from './dom/selector-engine'
|
||||
@@ -369,12 +368,7 @@ class Dropdown extends BaseComponent {
|
||||
// Static
|
||||
|
||||
static dropdownInterface(element, config) {
|
||||
let data = Data.get(element, DATA_KEY)
|
||||
const _config = typeof config === 'object' ? config : null
|
||||
|
||||
if (!data) {
|
||||
data = new Dropdown(element, _config)
|
||||
}
|
||||
const data = Dropdown.getOrCreateInstance(element, config)
|
||||
|
||||
if (typeof config === 'string') {
|
||||
if (typeof data[config] === 'undefined') {
|
||||
@@ -399,7 +393,7 @@ class Dropdown extends BaseComponent {
|
||||
const toggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE)
|
||||
|
||||
for (let i = 0, len = toggles.length; i < len; i++) {
|
||||
const context = Data.get(toggles[i], DATA_KEY)
|
||||
const context = Dropdown.getInstance(toggles[i])
|
||||
if (!context || context._config.autoClose === false) {
|
||||
continue
|
||||
}
|
||||
|
Reference in New Issue
Block a user