aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/twbs/bootstrap/js/src/dom/selector-engine.js
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/twbs/bootstrap/js/src/dom/selector-engine.js')
-rw-r--r--vendor/twbs/bootstrap/js/src/dom/selector-engine.js29
1 files changed, 10 insertions, 19 deletions
diff --git a/vendor/twbs/bootstrap/js/src/dom/selector-engine.js b/vendor/twbs/bootstrap/js/src/dom/selector-engine.js
index 54f270f4c..d2af46ff6 100644
--- a/vendor/twbs/bootstrap/js/src/dom/selector-engine.js
+++ b/vendor/twbs/bootstrap/js/src/dom/selector-engine.js
@@ -1,20 +1,16 @@
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.1.3): dom/selector-engine.js
+ * Bootstrap (v5.2.0): dom/selector-engine.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
+import { isDisabled, isVisible } from '../util/index'
+
/**
- * ------------------------------------------------------------------------
* Constants
- * ------------------------------------------------------------------------
*/
-import { isDisabled, isVisible } from '../util/index'
-
-const NODE_TEXT = 3
-
const SelectorEngine = {
find(selector, element = document.documentElement) {
return [].concat(...Element.prototype.querySelectorAll.call(element, selector))
@@ -25,21 +21,16 @@ const SelectorEngine = {
},
children(element, selector) {
- return [].concat(...element.children)
- .filter(child => child.matches(selector))
+ return [].concat(...element.children).filter(child => child.matches(selector))
},
parents(element, selector) {
const parents = []
+ let ancestor = element.parentNode.closest(selector)
- let ancestor = element.parentNode
-
- while (ancestor && ancestor.nodeType === Node.ELEMENT_NODE && ancestor.nodeType !== NODE_TEXT) {
- if (ancestor.matches(selector)) {
- parents.push(ancestor)
- }
-
- ancestor = ancestor.parentNode
+ while (ancestor) {
+ parents.push(ancestor)
+ ancestor = ancestor.parentNode.closest(selector)
}
return parents
@@ -58,7 +49,7 @@ const SelectorEngine = {
return []
},
-
+ // TODO: this is now unused; remove later along with prev()
next(element, selector) {
let next = element.nextElementSibling
@@ -83,7 +74,7 @@ const SelectorEngine = {
'details',
'[tabindex]',
'[contenteditable="true"]'
- ].map(selector => `${selector}:not([tabindex^="-"])`).join(', ')
+ ].map(selector => `${selector}:not([tabindex^="-"])`).join(',')
return this.find(focusables, element).filter(el => !isDisabled(el) && isVisible(el))
}