2019-03-01 17:31:34 +01:00
|
|
|
/*!
|
2022-09-07 17:31:39 +02:00
|
|
|
* Bootstrap selector-engine.js v5.2.1 (https://getbootstrap.com/)
|
2022-05-13 08:07:23 +02:00
|
|
|
* Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
2020-06-16 20:50:01 +02:00
|
|
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
2019-03-01 17:31:34 +01:00
|
|
|
*/
|
|
|
|
(function (global, factory) {
|
2022-05-13 08:07:23 +02:00
|
|
|
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';
|
2019-03-01 17:31:34 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* --------------------------------------------------------------------------
|
2022-09-07 17:31:39 +02:00
|
|
|
* Bootstrap (v5.2.1): dom/selector-engine.js
|
2020-06-16 20:50:01 +02:00
|
|
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
2019-03-01 17:31:34 +01:00
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
/**
|
2022-05-13 08:07:23 +02:00
|
|
|
* Constants
|
2019-03-01 17:31:34 +01:00
|
|
|
*/
|
2022-05-13 08:07:23 +02:00
|
|
|
|
2021-03-23 17:26:54 +01:00
|
|
|
const SelectorEngine = {
|
|
|
|
find(selector, element = document.documentElement) {
|
|
|
|
return [].concat(...Element.prototype.querySelectorAll.call(element, selector));
|
2019-03-01 17:31:34 +01:00
|
|
|
},
|
|
|
|
|
2021-03-23 17:26:54 +01:00
|
|
|
findOne(selector, element = document.documentElement) {
|
2020-11-11 18:07:37 +01:00
|
|
|
return Element.prototype.querySelector.call(element, selector);
|
2019-03-01 17:31:34 +01:00
|
|
|
},
|
2020-03-28 11:29:08 +01:00
|
|
|
|
2021-03-23 17:26:54 +01:00
|
|
|
children(element, selector) {
|
|
|
|
return [].concat(...element.children).filter(child => child.matches(selector));
|
2019-03-01 17:31:34 +01:00
|
|
|
},
|
2021-03-23 17:26:54 +01:00
|
|
|
|
|
|
|
parents(element, selector) {
|
|
|
|
const parents = [];
|
2022-05-13 08:07:23 +02:00
|
|
|
let ancestor = element.parentNode.closest(selector);
|
2019-03-01 17:31:34 +01:00
|
|
|
|
2022-05-13 08:07:23 +02:00
|
|
|
while (ancestor) {
|
|
|
|
parents.push(ancestor);
|
|
|
|
ancestor = ancestor.parentNode.closest(selector);
|
2019-03-01 17:31:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return parents;
|
|
|
|
},
|
2021-03-23 17:26:54 +01:00
|
|
|
|
|
|
|
prev(element, selector) {
|
|
|
|
let previous = element.previousElementSibling;
|
2020-03-28 11:29:08 +01:00
|
|
|
|
|
|
|
while (previous) {
|
|
|
|
if (previous.matches(selector)) {
|
|
|
|
return [previous];
|
|
|
|
}
|
|
|
|
|
|
|
|
previous = previous.previousElementSibling;
|
|
|
|
}
|
2019-03-01 17:31:34 +01:00
|
|
|
|
2020-03-28 11:29:08 +01:00
|
|
|
return [];
|
|
|
|
},
|
2021-03-23 17:26:54 +01:00
|
|
|
|
2022-05-13 08:07:23 +02:00
|
|
|
// TODO: this is now unused; remove later along with prev()
|
2021-03-23 17:26:54 +01:00
|
|
|
next(element, selector) {
|
|
|
|
let next = element.nextElementSibling;
|
2020-03-28 11:29:08 +01:00
|
|
|
|
|
|
|
while (next) {
|
2021-02-10 17:14:51 +01:00
|
|
|
if (next.matches(selector)) {
|
2020-03-28 11:29:08 +01:00
|
|
|
return [next];
|
2019-03-01 17:31:34 +01:00
|
|
|
}
|
|
|
|
|
2020-03-28 11:29:08 +01:00
|
|
|
next = next.nextElementSibling;
|
2019-03-01 17:31:34 +01:00
|
|
|
}
|
|
|
|
|
2020-03-28 11:29:08 +01:00
|
|
|
return [];
|
2021-08-04 17:41:51 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
focusableChildren(element) {
|
2022-05-13 08:07:23 +02:00
|
|
|
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));
|
2019-03-01 17:31:34 +01:00
|
|
|
}
|
2021-03-23 17:26:54 +01:00
|
|
|
|
2019-03-01 17:31:34 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
return SelectorEngine;
|
|
|
|
|
2021-10-05 17:50:18 +02:00
|
|
|
}));
|
2019-05-08 15:11:24 +02:00
|
|
|
//# sourceMappingURL=selector-engine.js.map
|