2019-03-01 17:31:34 +01:00
|
|
|
/*!
|
2021-05-13 18:22:20 +02:00
|
|
|
* Bootstrap selector-engine.js v5.0.1 (https://getbootstrap.com/)
|
2021-02-10 17:14:51 +01:00
|
|
|
* Copyright 2011-2021 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) {
|
2020-11-11 18:07:37 +01:00
|
|
|
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';
|
2019-03-01 17:31:34 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* --------------------------------------------------------------------------
|
2021-05-13 18:22:20 +02:00
|
|
|
* Bootstrap (v5.0.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
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
*/
|
2020-11-11 18:07:37 +01:00
|
|
|
|
2019-03-01 17:31:34 +01:00
|
|
|
/**
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
* Constants
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
*/
|
2021-03-23 17:26:54 +01:00
|
|
|
const NODE_TEXT = 3;
|
|
|
|
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 = [];
|
|
|
|
let ancestor = element.parentNode;
|
2019-03-01 17:31:34 +01:00
|
|
|
|
|
|
|
while (ancestor && ancestor.nodeType === Node.ELEMENT_NODE && ancestor.nodeType !== NODE_TEXT) {
|
2021-02-10 17:14:51 +01:00
|
|
|
if (ancestor.matches(selector)) {
|
2019-03-01 17:31:34 +01:00
|
|
|
parents.push(ancestor);
|
|
|
|
}
|
|
|
|
|
|
|
|
ancestor = ancestor.parentNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
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 [];
|
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;
|
|
|
|
|
2019-11-08 09:11:23 +01:00
|
|
|
})));
|
2019-05-08 15:11:24 +02:00
|
|
|
//# sourceMappingURL=selector-engine.js.map
|