aboutsummaryrefslogtreecommitdiff
path: root/js/dist/dom/selector-engine.js
diff options
context:
space:
mode:
authorXhmikosR <[email protected]>2021-08-18 07:29:56 +0300
committerGitHub <[email protected]>2021-08-18 07:29:56 +0300
commit433a148c9e61aa942801fd8101dfa5c4045fdaed (patch)
treef41db59fd06019169df5ea0338213ec0e298f226 /js/dist/dom/selector-engine.js
parentb97cfa163b5098db70e03b27c91fca5dde9c267e (diff)
parent18b3e1ac71f73d006756684a285c5a818e2d1454 (diff)
downloadbootstrap-global-focus-vars.tar.xz
bootstrap-global-focus-vars.zip
Merge branch 'main' into global-focus-varsglobal-focus-vars
Diffstat (limited to 'js/dist/dom/selector-engine.js')
-rw-r--r--js/dist/dom/selector-engine.js96
1 files changed, 65 insertions, 31 deletions
diff --git a/js/dist/dom/selector-engine.js b/js/dist/dom/selector-engine.js
index 6b2297e35..1d260dce7 100644
--- a/js/dist/dom/selector-engine.js
+++ b/js/dist/dom/selector-engine.js
@@ -1,5 +1,5 @@
/*!
- * Bootstrap selector-engine.js v5.0.0-beta2 (https://getbootstrap.com/)
+ * Bootstrap selector-engine.js v5.1.0 (https://getbootstrap.com/)
* Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
@@ -11,44 +11,70 @@
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.0-beta2): dom/selector-engine.js
+ * Bootstrap (v5.1.0): util/index.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
- /**
- * ------------------------------------------------------------------------
- * Constants
- * ------------------------------------------------------------------------
- */
- var NODE_TEXT = 3;
- var SelectorEngine = {
- find: function find(selector, element) {
- var _ref;
+ const isElement = obj => {
+ if (!obj || typeof obj !== 'object') {
+ return false;
+ }
- if (element === void 0) {
- element = document.documentElement;
- }
+ if (typeof obj.jquery !== 'undefined') {
+ obj = obj[0];
+ }
+
+ return typeof obj.nodeType !== 'undefined';
+ };
+
+ const isVisible = element => {
+ if (!isElement(element) || element.getClientRects().length === 0) {
+ return false;
+ }
+
+ return getComputedStyle(element).getPropertyValue('visibility') === 'visible';
+ };
+
+ const isDisabled = element => {
+ if (!element || element.nodeType !== Node.ELEMENT_NODE) {
+ return true;
+ }
+
+ if (element.classList.contains('disabled')) {
+ return true;
+ }
- return (_ref = []).concat.apply(_ref, Element.prototype.querySelectorAll.call(element, selector));
+ if (typeof element.disabled !== 'undefined') {
+ return element.disabled;
+ }
+
+ return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false';
+ };
+
+ /**
+ * --------------------------------------------------------------------------
+ * Bootstrap (v5.1.0): dom/selector-engine.js
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
+ * --------------------------------------------------------------------------
+ */
+ const NODE_TEXT = 3;
+ const SelectorEngine = {
+ find(selector, element = document.documentElement) {
+ return [].concat(...Element.prototype.querySelectorAll.call(element, selector));
},
- findOne: function findOne(selector, element) {
- if (element === void 0) {
- element = document.documentElement;
- }
+ findOne(selector, element = document.documentElement) {
return Element.prototype.querySelector.call(element, selector);
},
- children: function children(element, selector) {
- var _ref2;
- return (_ref2 = []).concat.apply(_ref2, element.children).filter(function (child) {
- return child.matches(selector);
- });
+ children(element, selector) {
+ return [].concat(...element.children).filter(child => child.matches(selector));
},
- parents: function parents(element, selector) {
- var parents = [];
- var ancestor = element.parentNode;
+
+ parents(element, selector) {
+ const parents = [];
+ let ancestor = element.parentNode;
while (ancestor && ancestor.nodeType === Node.ELEMENT_NODE && ancestor.nodeType !== NODE_TEXT) {
if (ancestor.matches(selector)) {
@@ -60,8 +86,9 @@
return parents;
},
- prev: function prev(element, selector) {
- var previous = element.previousElementSibling;
+
+ prev(element, selector) {
+ let previous = element.previousElementSibling;
while (previous) {
if (previous.matches(selector)) {
@@ -73,8 +100,9 @@
return [];
},
- next: function next(element, selector) {
- var next = element.nextElementSibling;
+
+ next(element, selector) {
+ let next = element.nextElementSibling;
while (next) {
if (next.matches(selector)) {
@@ -85,7 +113,13 @@
}
return [];
+ },
+
+ focusableChildren(element) {
+ const focusables = ['a', 'button', 'input', 'textarea', 'select', 'details', '[tabindex]', '[contenteditable="true"]'].map(selector => `${selector}:not([tabindex^="-"])`).join(', ');
+ return this.find(focusables, element).filter(el => !isDisabled(el) && isVisible(el));
}
+
};
return SelectorEngine;