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

github.com/twbs/bootstrap-rubygem.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'assets/javascripts/bootstrap/dom/selector-engine.js')
-rw-r--r--assets/javascripts/bootstrap/dom/selector-engine.js74
1 files changed, 16 insertions, 58 deletions
diff --git a/assets/javascripts/bootstrap/dom/selector-engine.js b/assets/javascripts/bootstrap/dom/selector-engine.js
index 637133b..8c23ee7 100644
--- a/assets/javascripts/bootstrap/dom/selector-engine.js
+++ b/assets/javascripts/bootstrap/dom/selector-engine.js
@@ -1,64 +1,24 @@
/*!
- * Bootstrap selector-engine.js v5.1.3 (https://getbootstrap.com/)
- * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
+ * Bootstrap selector-engine.js v5.2.0 (https://getbootstrap.com/)
+ * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
(function (global, factory) {
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
- typeof define === 'function' && define.amd ? define(factory) :
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.SelectorEngine = factory());
-})(this, (function () { 'use strict';
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('../util/index')) :
+ typeof define === 'function' && define.amd ? define(['../util/index'], factory) :
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.SelectorEngine = factory(global.Index));
+})(this, (function (index) { 'use strict';
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.1.3): util/index.js
+ * Bootstrap (v5.2.0): dom/selector-engine.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
-
- const isElement = obj => {
- if (!obj || typeof obj !== 'object') {
- return false;
- }
-
- 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;
- }
-
- if (typeof element.disabled !== 'undefined') {
- return element.disabled;
- }
-
- return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false';
- };
-
/**
- * --------------------------------------------------------------------------
- * Bootstrap (v5.1.3): dom/selector-engine.js
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
- * --------------------------------------------------------------------------
+ * Constants
*/
- const NODE_TEXT = 3;
+
const SelectorEngine = {
find(selector, element = document.documentElement) {
return [].concat(...Element.prototype.querySelectorAll.call(element, selector));
@@ -74,14 +34,11 @@
parents(element, selector) {
const parents = [];
- let ancestor = element.parentNode;
-
- while (ancestor && ancestor.nodeType === Node.ELEMENT_NODE && ancestor.nodeType !== NODE_TEXT) {
- if (ancestor.matches(selector)) {
- parents.push(ancestor);
- }
+ let ancestor = element.parentNode.closest(selector);
- ancestor = ancestor.parentNode;
+ while (ancestor) {
+ parents.push(ancestor);
+ ancestor = ancestor.parentNode.closest(selector);
}
return parents;
@@ -101,6 +58,7 @@
return [];
},
+ // TODO: this is now unused; remove later along with prev()
next(element, selector) {
let next = element.nextElementSibling;
@@ -116,8 +74,8 @@
},
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));
+ const focusables = ['a', 'button', 'input', 'textarea', 'select', 'details', '[tabindex]', '[contenteditable="true"]'].map(selector => `${selector}:not([tabindex^="-"])`).join(',');
+ return this.find(focusables, element).filter(el => !index.isDisabled(el) && index.isVisible(el));
}
};