1 | /*!
|
---|
2 | * Bootstrap selector-engine.js v5.1.3 (https://getbootstrap.com/)
|
---|
3 | * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
---|
4 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
---|
5 | */
|
---|
6 | (function (global, factory) {
|
---|
7 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
---|
8 | typeof define === 'function' && define.amd ? define(factory) :
|
---|
9 | (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.SelectorEngine = factory());
|
---|
10 | })(this, (function () { 'use strict';
|
---|
11 |
|
---|
12 | /**
|
---|
13 | * --------------------------------------------------------------------------
|
---|
14 | * Bootstrap (v5.1.3): util/index.js
|
---|
15 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
---|
16 | * --------------------------------------------------------------------------
|
---|
17 | */
|
---|
18 |
|
---|
19 | const isElement = obj => {
|
---|
20 | if (!obj || typeof obj !== 'object') {
|
---|
21 | return false;
|
---|
22 | }
|
---|
23 |
|
---|
24 | if (typeof obj.jquery !== 'undefined') {
|
---|
25 | obj = obj[0];
|
---|
26 | }
|
---|
27 |
|
---|
28 | return typeof obj.nodeType !== 'undefined';
|
---|
29 | };
|
---|
30 |
|
---|
31 | const isVisible = element => {
|
---|
32 | if (!isElement(element) || element.getClientRects().length === 0) {
|
---|
33 | return false;
|
---|
34 | }
|
---|
35 |
|
---|
36 | return getComputedStyle(element).getPropertyValue('visibility') === 'visible';
|
---|
37 | };
|
---|
38 |
|
---|
39 | const isDisabled = element => {
|
---|
40 | if (!element || element.nodeType !== Node.ELEMENT_NODE) {
|
---|
41 | return true;
|
---|
42 | }
|
---|
43 |
|
---|
44 | if (element.classList.contains('disabled')) {
|
---|
45 | return true;
|
---|
46 | }
|
---|
47 |
|
---|
48 | if (typeof element.disabled !== 'undefined') {
|
---|
49 | return element.disabled;
|
---|
50 | }
|
---|
51 |
|
---|
52 | return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false';
|
---|
53 | };
|
---|
54 |
|
---|
55 | /**
|
---|
56 | * --------------------------------------------------------------------------
|
---|
57 | * Bootstrap (v5.1.3): dom/selector-engine.js
|
---|
58 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
---|
59 | * --------------------------------------------------------------------------
|
---|
60 | */
|
---|
61 | const NODE_TEXT = 3;
|
---|
62 | const SelectorEngine = {
|
---|
63 | find(selector, element = document.documentElement) {
|
---|
64 | return [].concat(...Element.prototype.querySelectorAll.call(element, selector));
|
---|
65 | },
|
---|
66 |
|
---|
67 | findOne(selector, element = document.documentElement) {
|
---|
68 | return Element.prototype.querySelector.call(element, selector);
|
---|
69 | },
|
---|
70 |
|
---|
71 | children(element, selector) {
|
---|
72 | return [].concat(...element.children).filter(child => child.matches(selector));
|
---|
73 | },
|
---|
74 |
|
---|
75 | parents(element, selector) {
|
---|
76 | const parents = [];
|
---|
77 | let ancestor = element.parentNode;
|
---|
78 |
|
---|
79 | while (ancestor && ancestor.nodeType === Node.ELEMENT_NODE && ancestor.nodeType !== NODE_TEXT) {
|
---|
80 | if (ancestor.matches(selector)) {
|
---|
81 | parents.push(ancestor);
|
---|
82 | }
|
---|
83 |
|
---|
84 | ancestor = ancestor.parentNode;
|
---|
85 | }
|
---|
86 |
|
---|
87 | return parents;
|
---|
88 | },
|
---|
89 |
|
---|
90 | prev(element, selector) {
|
---|
91 | let previous = element.previousElementSibling;
|
---|
92 |
|
---|
93 | while (previous) {
|
---|
94 | if (previous.matches(selector)) {
|
---|
95 | return [previous];
|
---|
96 | }
|
---|
97 |
|
---|
98 | previous = previous.previousElementSibling;
|
---|
99 | }
|
---|
100 |
|
---|
101 | return [];
|
---|
102 | },
|
---|
103 |
|
---|
104 | next(element, selector) {
|
---|
105 | let next = element.nextElementSibling;
|
---|
106 |
|
---|
107 | while (next) {
|
---|
108 | if (next.matches(selector)) {
|
---|
109 | return [next];
|
---|
110 | }
|
---|
111 |
|
---|
112 | next = next.nextElementSibling;
|
---|
113 | }
|
---|
114 |
|
---|
115 | return [];
|
---|
116 | },
|
---|
117 |
|
---|
118 | focusableChildren(element) {
|
---|
119 | const focusables = ['a', 'button', 'input', 'textarea', 'select', 'details', '[tabindex]', '[contenteditable="true"]'].map(selector => `${selector}:not([tabindex^="-"])`).join(', ');
|
---|
120 | return this.find(focusables, element).filter(el => !isDisabled(el) && isVisible(el));
|
---|
121 | }
|
---|
122 |
|
---|
123 | };
|
---|
124 |
|
---|
125 | return SelectorEngine;
|
---|
126 |
|
---|
127 | }));
|
---|
128 | //# sourceMappingURL=selector-engine.js.map
|
---|