diff options
author | Mario <mario@mariovavti.com> | 2023-01-20 11:05:15 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2023-01-20 11:05:15 +0000 |
commit | 9dc949b62c6b5e3c8872211f71b11714d9d22b22 (patch) | |
tree | 38c06e7a128742e219eb74d6adb035f2f106918a /vendor/twbs/bootstrap/js/dist/dom/selector-engine.js | |
parent | 40394b94d7c8a8bf1f61f5482195164fff434b90 (diff) | |
download | volse-hubzilla-9dc949b62c6b5e3c8872211f71b11714d9d22b22.tar.gz volse-hubzilla-9dc949b62c6b5e3c8872211f71b11714d9d22b22.tar.bz2 volse-hubzilla-9dc949b62c6b5e3c8872211f71b11714d9d22b22.zip |
native dark theme initial checkin
Diffstat (limited to 'vendor/twbs/bootstrap/js/dist/dom/selector-engine.js')
-rw-r--r-- | vendor/twbs/bootstrap/js/dist/dom/selector-engine.js | 63 |
1 files changed, 40 insertions, 23 deletions
diff --git a/vendor/twbs/bootstrap/js/dist/dom/selector-engine.js b/vendor/twbs/bootstrap/js/dist/dom/selector-engine.js index 51d36c2a6..880f3b268 100644 --- a/vendor/twbs/bootstrap/js/dist/dom/selector-engine.js +++ b/vendor/twbs/bootstrap/js/dist/dom/selector-engine.js @@ -1,83 +1,100 @@ /*! - * Bootstrap selector-engine.js v5.2.2 (https://getbootstrap.com/) + * Bootstrap selector-engine.js v5.3.0-alpha1 (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(require('../util/index')) : + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('../util/index.js')) : 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'; +})(this, (function (index_js) { 'use strict'; /** * -------------------------------------------------------------------------- - * Bootstrap (v5.2.2): dom/selector-engine.js + * Bootstrap (v5.3.0-alpha1): dom/selector-engine.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ - /** - * Constants - */ + const getSelector = element => { + let selector = element.getAttribute('data-bs-target'); + if (!selector || selector === '#') { + let hrefAttribute = element.getAttribute('href'); + + // The only valid content that could double as a selector are IDs or classes, + // so everything starting with `#` or `.`. If a "real" URL is used as the selector, + // `document.querySelector` will rightfully complain it is invalid. + // See https://github.com/twbs/bootstrap/issues/32273 + if (!hrefAttribute || !hrefAttribute.includes('#') && !hrefAttribute.startsWith('.')) { + return null; + } + // Just in case some CMS puts out a full URL with the anchor appended + if (hrefAttribute.includes('#') && !hrefAttribute.startsWith('#')) { + hrefAttribute = `#${hrefAttribute.split('#')[1]}`; + } + selector = hrefAttribute && hrefAttribute !== '#' ? hrefAttribute.trim() : null; + } + return index_js.parseSelector(selector); + }; const SelectorEngine = { find(selector, element = document.documentElement) { return [].concat(...Element.prototype.querySelectorAll.call(element, selector)); }, - findOne(selector, element = document.documentElement) { return Element.prototype.querySelector.call(element, selector); }, - children(element, selector) { return [].concat(...element.children).filter(child => child.matches(selector)); }, - parents(element, selector) { const parents = []; let ancestor = element.parentNode.closest(selector); - while (ancestor) { parents.push(ancestor); ancestor = ancestor.parentNode.closest(selector); } - return parents; }, - prev(element, selector) { let previous = element.previousElementSibling; - while (previous) { if (previous.matches(selector)) { return [previous]; } - previous = previous.previousElementSibling; } - return []; }, - // TODO: this is now unused; remove later along with prev() next(element, selector) { let next = element.nextElementSibling; - while (next) { if (next.matches(selector)) { return [next]; } - next = next.nextElementSibling; } - return []; }, - 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 => !index.isDisabled(el) && index.isVisible(el)); + return this.find(focusables, element).filter(el => !index_js.isDisabled(el) && index_js.isVisible(el)); + }, + getSelectorFromElement(element) { + const selector = getSelector(element); + if (selector) { + return SelectorEngine.findOne(selector) ? selector : null; + } + return null; + }, + getElementFromSelector(element) { + const selector = getSelector(element); + return selector ? SelectorEngine.findOne(selector) : null; + }, + getMultipleElementsFromSelector(element) { + const selector = getSelector(element); + return selector ? SelectorEngine.find(selector) : []; } - }; return SelectorEngine; |