aboutsummaryrefslogtreecommitdiff
path: root/js/src/base-component.js
diff options
context:
space:
mode:
authorGeoSot <[email protected]>2021-06-03 18:53:27 +0300
committerGitHub <[email protected]>2021-06-03 18:53:27 +0300
commitc98657b8303150bfda3bdea750055b83a29b27a3 (patch)
tree6f7b347461e3fdd380f0d4e990440e6fc427af61 /js/src/base-component.js
parent4a5029ea29ac75243dfec68153051292fc70f5cf (diff)
downloadbootstrap-c98657b8303150bfda3bdea750055b83a29b27a3.tar.xz
bootstrap-c98657b8303150bfda3bdea750055b83a29b27a3.zip
Add `getOrCreateInstance` method in base-component (#33276)
Co-authored-by: Rohit Sharma <[email protected]> Co-authored-by: XhmikosR <[email protected]>
Diffstat (limited to 'js/src/base-component.js')
-rw-r--r--js/src/base-component.js4
1 files changed, 4 insertions, 0 deletions
diff --git a/js/src/base-component.js b/js/src/base-component.js
index 368cc99c8..cadd53d26 100644
--- a/js/src/base-component.js
+++ b/js/src/base-component.js
@@ -51,6 +51,10 @@ class BaseComponent {
return Data.get(element, this.DATA_KEY)
}
+ static getOrCreateInstance(element, config = {}) {
+ return this.getInstance(element) || new this(element, typeof config === 'object' ? config : null)
+ }
+
static get VERSION() {
return VERSION
}