2019-03-01 17:31:34 +01:00
|
|
|
/*!
|
2020-05-13 21:36:00 +02:00
|
|
|
* Bootstrap selector-engine.js v5.0.0-alpha1 (https://getbootstrap.com/)
|
2020-03-28 11:29:08 +01:00
|
|
|
* Copyright 2011-2020 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) {
|
2019-07-12 23:56:26 +02:00
|
|
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./polyfill.js')) :
|
|
|
|
typeof define === 'function' && define.amd ? define(['./polyfill.js'], factory) :
|
|
|
|
(global = global || self, global.SelectorEngine = factory(global.Polyfill));
|
2019-11-08 09:11:23 +01:00
|
|
|
}(this, (function (polyfill_js) { 'use strict';
|
2019-03-01 17:31:34 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* --------------------------------------------------------------------------
|
2020-05-13 21:36:00 +02:00
|
|
|
* Bootstrap (v5.0.0-alpha1): 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
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
* Constants
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
var NODE_TEXT = 3;
|
|
|
|
var SelectorEngine = {
|
2019-07-12 23:56:26 +02:00
|
|
|
matches: function matches(element, selector) {
|
2020-03-28 11:29:08 +01:00
|
|
|
return element.matches(selector);
|
2019-03-01 17:31:34 +01:00
|
|
|
},
|
2019-07-12 23:56:26 +02:00
|
|
|
find: function find(selector, element) {
|
2020-03-28 11:29:08 +01:00
|
|
|
var _ref;
|
|
|
|
|
2019-03-01 17:31:34 +01:00
|
|
|
if (element === void 0) {
|
|
|
|
element = document.documentElement;
|
|
|
|
}
|
|
|
|
|
2020-03-28 11:29:08 +01:00
|
|
|
return (_ref = []).concat.apply(_ref, polyfill_js.find.call(element, selector));
|
2019-03-01 17:31:34 +01:00
|
|
|
},
|
2019-07-12 23:56:26 +02:00
|
|
|
findOne: function findOne(selector, element) {
|
2019-03-01 17:31:34 +01:00
|
|
|
if (element === void 0) {
|
|
|
|
element = document.documentElement;
|
|
|
|
}
|
|
|
|
|
2019-07-12 23:56:26 +02:00
|
|
|
return polyfill_js.findOne.call(element, selector);
|
2019-03-01 17:31:34 +01:00
|
|
|
},
|
|
|
|
children: function children(element, selector) {
|
2020-03-28 11:29:08 +01:00
|
|
|
var _ref2;
|
|
|
|
|
|
|
|
var children = (_ref2 = []).concat.apply(_ref2, element.children);
|
2019-03-01 17:31:34 +01:00
|
|
|
|
|
|
|
return children.filter(function (child) {
|
2020-03-28 11:29:08 +01:00
|
|
|
return child.matches(selector);
|
2019-03-01 17:31:34 +01:00
|
|
|
});
|
|
|
|
},
|
|
|
|
parents: function parents(element, selector) {
|
|
|
|
var parents = [];
|
|
|
|
var ancestor = element.parentNode;
|
|
|
|
|
|
|
|
while (ancestor && ancestor.nodeType === Node.ELEMENT_NODE && ancestor.nodeType !== NODE_TEXT) {
|
|
|
|
if (this.matches(ancestor, selector)) {
|
|
|
|
parents.push(ancestor);
|
|
|
|
}
|
|
|
|
|
|
|
|
ancestor = ancestor.parentNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
return parents;
|
|
|
|
},
|
|
|
|
prev: function prev(element, selector) {
|
2020-03-28 11:29:08 +01:00
|
|
|
var previous = element.previousElementSibling;
|
|
|
|
|
|
|
|
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 [];
|
|
|
|
},
|
|
|
|
next: function next(element, selector) {
|
|
|
|
var next = element.nextElementSibling;
|
|
|
|
|
|
|
|
while (next) {
|
|
|
|
if (this.matches(next, selector)) {
|
|
|
|
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
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return SelectorEngine;
|
|
|
|
|
2019-11-08 09:11:23 +01:00
|
|
|
})));
|
2019-05-08 15:11:24 +02:00
|
|
|
//# sourceMappingURL=selector-engine.js.map
|