From fca04c07131a81e625a516cf7b98a8c7df0df1c1 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Fri, 13 May 2022 09:07:23 +0300 Subject: Dist --- js/dist/dom/selector-engine.js | 74 +++++++++--------------------------------- 1 file changed, 16 insertions(+), 58 deletions(-) (limited to 'js/dist/dom/selector-engine.js') diff --git a/js/dist/dom/selector-engine.js b/js/dist/dom/selector-engine.js index 8cf7e2925..59a562674 100644 --- a/js/dist/dom/selector-engine.js +++ b/js/dist/dom/selector-engine.js @@ -1,64 +1,24 @@ /*! - * Bootstrap selector-engine.js v5.1.3 (https://getbootstrap.com/) - * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Bootstrap selector-engine.js v5.2.0-beta1 (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() : - typeof define === 'function' && define.amd ? define(factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.SelectorEngine = factory()); -})(this, (function () { 'use strict'; + 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'; /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/index.js + * Bootstrap (v5.2.0-beta1): dom/selector-engine.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ - - const isElement = obj => { - if (!obj || typeof obj !== 'object') { - return false; - } - - if (typeof obj.jquery !== 'undefined') { - obj = obj[0]; - } - - return typeof obj.nodeType !== 'undefined'; - }; - - const isVisible = element => { - if (!isElement(element) || element.getClientRects().length === 0) { - return false; - } - - return getComputedStyle(element).getPropertyValue('visibility') === 'visible'; - }; - - const isDisabled = element => { - if (!element || element.nodeType !== Node.ELEMENT_NODE) { - return true; - } - - if (element.classList.contains('disabled')) { - return true; - } - - if (typeof element.disabled !== 'undefined') { - return element.disabled; - } - - return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false'; - }; - /** - * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): dom/selector-engine.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - * -------------------------------------------------------------------------- + * Constants */ - const NODE_TEXT = 3; + const SelectorEngine = { find(selector, element = document.documentElement) { return [].concat(...Element.prototype.querySelectorAll.call(element, selector)); @@ -74,14 +34,11 @@ parents(element, selector) { const parents = []; - let ancestor = element.parentNode; - - while (ancestor && ancestor.nodeType === Node.ELEMENT_NODE && ancestor.nodeType !== NODE_TEXT) { - if (ancestor.matches(selector)) { - parents.push(ancestor); - } + let ancestor = element.parentNode.closest(selector); - ancestor = ancestor.parentNode; + while (ancestor) { + parents.push(ancestor); + ancestor = ancestor.parentNode.closest(selector); } return parents; @@ -101,6 +58,7 @@ return []; }, + // TODO: this is now unused; remove later along with prev() next(element, selector) { let next = element.nextElementSibling; @@ -116,8 +74,8 @@ }, 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 => !isDisabled(el) && isVisible(el)); + 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)); } }; -- cgit v1.2.3 From edf9c40956d19e6ab3f9151bfe0dfac6be06fa21 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Tue, 19 Jul 2022 18:43:58 +0300 Subject: Release v5.2.0 (#36768) * Bump version to 5.2.0 * Dist * Update masthead.html --- js/dist/dom/selector-engine.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/dist/dom/selector-engine.js') diff --git a/js/dist/dom/selector-engine.js b/js/dist/dom/selector-engine.js index 59a562674..2e72f3c5e 100644 --- a/js/dist/dom/selector-engine.js +++ b/js/dist/dom/selector-engine.js @@ -1,5 +1,5 @@ /*! - * Bootstrap selector-engine.js v5.2.0-beta1 (https://getbootstrap.com/) + * Bootstrap selector-engine.js v5.2.0 (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) */ @@ -11,7 +11,7 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.2.0-beta1): dom/selector-engine.js + * Bootstrap (v5.2.0): dom/selector-engine.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ -- cgit v1.2.3 From 23e50829f958ea1d741d63e2781716be037e4644 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Wed, 7 Sep 2022 18:31:39 +0300 Subject: Release v5.2.1 (#37098) * Bump version to v5.2.1. * Dist --- js/dist/dom/selector-engine.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/dist/dom/selector-engine.js') diff --git a/js/dist/dom/selector-engine.js b/js/dist/dom/selector-engine.js index 2e72f3c5e..41057a800 100644 --- a/js/dist/dom/selector-engine.js +++ b/js/dist/dom/selector-engine.js @@ -1,5 +1,5 @@ /*! - * Bootstrap selector-engine.js v5.2.0 (https://getbootstrap.com/) + * Bootstrap selector-engine.js v5.2.1 (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) */ @@ -11,7 +11,7 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.2.0): dom/selector-engine.js + * Bootstrap (v5.2.1): dom/selector-engine.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ -- cgit v1.2.3 From 961d5ff9844372a4e294980c667bbe7e0651cdeb Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Mon, 3 Oct 2022 10:44:02 +0300 Subject: Release v5.2.2 (#37236) * Bump version to v5.2.2 * Dist --- js/dist/dom/selector-engine.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/dist/dom/selector-engine.js') diff --git a/js/dist/dom/selector-engine.js b/js/dist/dom/selector-engine.js index 41057a800..51d36c2a6 100644 --- a/js/dist/dom/selector-engine.js +++ b/js/dist/dom/selector-engine.js @@ -1,5 +1,5 @@ /*! - * Bootstrap selector-engine.js v5.2.1 (https://getbootstrap.com/) + * Bootstrap selector-engine.js v5.2.2 (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) */ @@ -11,7 +11,7 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.2.1): dom/selector-engine.js + * Bootstrap (v5.2.2): dom/selector-engine.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ -- cgit v1.2.3 From cb021439c683d9805e2864c58095b92d405e9b11 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Mon, 21 Nov 2022 20:19:01 +0200 Subject: Dist --- js/dist/dom/selector-engine.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/dist/dom/selector-engine.js') diff --git a/js/dist/dom/selector-engine.js b/js/dist/dom/selector-engine.js index 51d36c2a6..67f860427 100644 --- a/js/dist/dom/selector-engine.js +++ b/js/dist/dom/selector-engine.js @@ -1,5 +1,5 @@ /*! - * Bootstrap selector-engine.js v5.2.2 (https://getbootstrap.com/) + * Bootstrap selector-engine.js v5.2.3 (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) */ @@ -11,7 +11,7 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.2.2): dom/selector-engine.js + * Bootstrap (v5.2.3): dom/selector-engine.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ -- cgit v1.2.3 From cf9454caa00872899215603e5e036d9a824b1b11 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Sat, 24 Dec 2022 18:37:22 +0200 Subject: Release v5.3.0-alpha1 (#37661) * Bump version to 5.3.0-alpha1 * Dist * Add docs versions updates * Update note in homepage hero Co-authored-by: Mark Otto --- js/dist/dom/selector-engine.js | 63 +++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 23 deletions(-) (limited to 'js/dist/dom/selector-engine.js') diff --git a/js/dist/dom/selector-engine.js b/js/dist/dom/selector-engine.js index 67f860427..880f3b268 100644 --- a/js/dist/dom/selector-engine.js +++ b/js/dist/dom/selector-engine.js @@ -1,83 +1,100 @@ /*! - * Bootstrap selector-engine.js v5.2.3 (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.3): 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; -- cgit v1.2.3 From c877cefcef18d6a60c5eaec8df469933e64e212a Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Fri, 24 Mar 2023 16:30:16 +0200 Subject: Release v5.3.0-alpha2 (#38244) * Bump version to 5.3.0-alpha2 * Dist --- js/dist/dom/selector-engine.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'js/dist/dom/selector-engine.js') diff --git a/js/dist/dom/selector-engine.js b/js/dist/dom/selector-engine.js index 880f3b268..b790574b6 100644 --- a/js/dist/dom/selector-engine.js +++ b/js/dist/dom/selector-engine.js @@ -1,6 +1,6 @@ /*! - * Bootstrap selector-engine.js v5.3.0-alpha1 (https://getbootstrap.com/) - * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Bootstrap selector-engine.js v5.3.0-alpha2 (https://getbootstrap.com/) + * Copyright 2011-2023 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ (function (global, factory) { @@ -11,7 +11,7 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.3.0-alpha1): dom/selector-engine.js + * Bootstrap dom/selector-engine.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ -- cgit v1.2.3 From ac576614a5515e429f27e756fad81d5aa05e95a6 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Mon, 3 Apr 2023 10:26:50 +0300 Subject: Release v5.3.0-alpha3 (#38357) * Bump version to 5.3.0-alpha3 * Dist --- js/dist/dom/selector-engine.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/dist/dom/selector-engine.js') diff --git a/js/dist/dom/selector-engine.js b/js/dist/dom/selector-engine.js index b790574b6..3fc7c4103 100644 --- a/js/dist/dom/selector-engine.js +++ b/js/dist/dom/selector-engine.js @@ -1,5 +1,5 @@ /*! - * Bootstrap selector-engine.js v5.3.0-alpha2 (https://getbootstrap.com/) + * Bootstrap selector-engine.js v5.3.0-alpha3 (https://getbootstrap.com/) * Copyright 2011-2023 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ -- cgit v1.2.3 From 60098ac499d30aa50575b0b7137391c06ef25429 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Tue, 30 May 2023 18:15:55 +0300 Subject: Release v5.3.0 (#38657) * Bump version to 5.3.0 * Dist --- js/dist/dom/selector-engine.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'js/dist/dom/selector-engine.js') diff --git a/js/dist/dom/selector-engine.js b/js/dist/dom/selector-engine.js index 3fc7c4103..dfbfb578e 100644 --- a/js/dist/dom/selector-engine.js +++ b/js/dist/dom/selector-engine.js @@ -1,5 +1,5 @@ /*! - * Bootstrap selector-engine.js v5.3.0-alpha3 (https://getbootstrap.com/) + * Bootstrap selector-engine.js v5.3.0 (https://getbootstrap.com/) * Copyright 2011-2023 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ @@ -15,6 +15,7 @@ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ + const getSelector = element => { let selector = element.getAttribute('data-bs-target'); if (!selector || selector === '#') { -- cgit v1.2.3 From 2a1bf52b73fc9a97f6fef75aa1b29b3e9f0288b3 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Wed, 26 Jul 2023 10:46:38 +0300 Subject: Release v5.3.1 (#38956) * Bump version to 5.3.1 * Dist --- js/dist/dom/selector-engine.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/dist/dom/selector-engine.js') diff --git a/js/dist/dom/selector-engine.js b/js/dist/dom/selector-engine.js index dfbfb578e..91e1491b2 100644 --- a/js/dist/dom/selector-engine.js +++ b/js/dist/dom/selector-engine.js @@ -1,5 +1,5 @@ /*! - * Bootstrap selector-engine.js v5.3.0 (https://getbootstrap.com/) + * Bootstrap selector-engine.js v5.3.1 (https://getbootstrap.com/) * Copyright 2011-2023 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ -- cgit v1.2.3 From 344e912d04b5b6a04482113eff20ab416ff01048 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20D=C3=A9ramond?= Date: Thu, 14 Sep 2023 16:19:27 +0200 Subject: Release v5.3.2 (#39173) * Bump version to 5.3.2 * Dist --- js/dist/dom/selector-engine.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'js/dist/dom/selector-engine.js') diff --git a/js/dist/dom/selector-engine.js b/js/dist/dom/selector-engine.js index 91e1491b2..6fd8c61d0 100644 --- a/js/dist/dom/selector-engine.js +++ b/js/dist/dom/selector-engine.js @@ -1,5 +1,5 @@ /*! - * Bootstrap selector-engine.js v5.3.1 (https://getbootstrap.com/) + * Bootstrap selector-engine.js v5.3.2 (https://getbootstrap.com/) * Copyright 2011-2023 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ @@ -33,9 +33,9 @@ if (hrefAttribute.includes('#') && !hrefAttribute.startsWith('#')) { hrefAttribute = `#${hrefAttribute.split('#')[1]}`; } - selector = hrefAttribute && hrefAttribute !== '#' ? hrefAttribute.trim() : null; + selector = hrefAttribute && hrefAttribute !== '#' ? index_js.parseSelector(hrefAttribute.trim()) : null; } - return index_js.parseSelector(selector); + return selector; }; const SelectorEngine = { find(selector, element = document.documentElement) { -- cgit v1.2.3 From 6e1f75f420f68e1d52733b8e407fc7c3766c9dba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20D=C3=A9ramond?= Date: Tue, 20 Feb 2024 16:14:29 +0100 Subject: Release v5.3.3 (#39524) * Release v5.3.3 * Dist --------- Co-authored-by: XhmikosR --- js/dist/dom/selector-engine.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'js/dist/dom/selector-engine.js') diff --git a/js/dist/dom/selector-engine.js b/js/dist/dom/selector-engine.js index 6fd8c61d0..993a88f13 100644 --- a/js/dist/dom/selector-engine.js +++ b/js/dist/dom/selector-engine.js @@ -1,6 +1,6 @@ /*! - * Bootstrap selector-engine.js v5.3.2 (https://getbootstrap.com/) - * Copyright 2011-2023 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Bootstrap selector-engine.js v5.3.3 (https://getbootstrap.com/) + * Copyright 2011-2024 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ (function (global, factory) { @@ -33,9 +33,9 @@ if (hrefAttribute.includes('#') && !hrefAttribute.startsWith('#')) { hrefAttribute = `#${hrefAttribute.split('#')[1]}`; } - selector = hrefAttribute && hrefAttribute !== '#' ? index_js.parseSelector(hrefAttribute.trim()) : null; + selector = hrefAttribute && hrefAttribute !== '#' ? hrefAttribute.trim() : null; } - return selector; + return selector ? selector.split(',').map(sel => index_js.parseSelector(sel)).join(',') : null; }; const SelectorEngine = { find(selector, element = document.documentElement) { -- cgit v1.2.3