Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeoSot <geo.sotis@gmail.com>2021-06-03 18:53:27 +0300
committerGitHub <noreply@github.com>2021-06-03 18:53:27 +0300
commitc98657b8303150bfda3bdea750055b83a29b27a3 (patch)
tree6f7b347461e3fdd380f0d4e990440e6fc427af61 /js/src/dropdown.js
parent4a5029ea29ac75243dfec68153051292fc70f5cf (diff)
Add `getOrCreateInstance` method in base-component (#33276)
Co-authored-by: Rohit Sharma <rohit2sharma95@gmail.com> Co-authored-by: XhmikosR <xhmikosr@gmail.com>
Diffstat (limited to 'js/src/dropdown.js')
-rw-r--r--js/src/dropdown.js10
1 files changed, 2 insertions, 8 deletions
diff --git a/js/src/dropdown.js b/js/src/dropdown.js
index 34beb65129..e79ac45910 100644
--- a/js/src/dropdown.js
+++ b/js/src/dropdown.js
@@ -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
}