mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-17 19:06:40 +02:00
Dist
This commit is contained in:
74
js/dist/dom/selector-engine.js
vendored
74
js/dist/dom/selector-engine.js
vendored
@@ -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-beta1 (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-beta1): 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;
|
||||
let ancestor = element.parentNode.closest(selector);
|
||||
|
||||
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;
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
};
|
||||
|
Reference in New Issue
Block a user