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:
Diffstat (limited to 'js/src/util/index.js')
-rw-r--r--js/src/util/index.js27
1 files changed, 26 insertions, 1 deletions
diff --git a/js/src/util/index.js b/js/src/util/index.js
index 0dd6b1d454..5ee211c73b 100644
--- a/js/src/util/index.js
+++ b/js/src/util/index.js
@@ -1,3 +1,5 @@
+import SelectorEngine from '../dom/selector-engine'
+
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0): util/index.js
@@ -100,7 +102,29 @@ const triggerTransitionEnd = element => {
element.dispatchEvent(new Event(TRANSITION_END))
}
-const isElement = obj => (obj[0] || obj).nodeType
+const isElement = obj => {
+ if (!obj || typeof obj !== 'object') {
+ return false
+ }
+
+ if (typeof obj.jquery !== 'undefined') {
+ obj = obj[0]
+ }
+
+ return typeof obj.nodeType !== 'undefined'
+}
+
+const getElement = obj => {
+ if (isElement(obj)) { // it's a jQuery object or a node element
+ return obj.jquery ? obj[0] : obj
+ }
+
+ if (typeof obj === 'string' && obj.length > 0) {
+ return SelectorEngine.findOne(obj)
+ }
+
+ return null
+}
const emulateTransitionEnd = (element, duration) => {
let called = false
@@ -238,6 +262,7 @@ const execute = callback => {
}
export {
+ getElement,
getUID,
getSelectorFromElement,
getElementFromSelector,