aboutsummaryrefslogtreecommitdiff
path: root/js/src/util/index.js
diff options
context:
space:
mode:
authorGeoSot <[email protected]>2022-11-06 20:31:43 +0200
committerGitHub <[email protected]>2022-11-06 20:31:43 +0200
commite81e7cda90026cdb2a05fcdadd2d66f48f0bbdc4 (patch)
treeea2459eebdf22e47438e3494a4955e173b5e9b66 /js/src/util/index.js
parent2b21094074b1bdabf9ebc4095c29398f8b2de237 (diff)
downloadbootstrap-e81e7cda90026cdb2a05fcdadd2d66f48f0bbdc4.tar.xz
bootstrap-e81e7cda90026cdb2a05fcdadd2d66f48f0bbdc4.zip
Move `getElementFromSelector` & `getSelectorFromElement` to SelectorEngine (#36027)
* Move `getElementFromSelector` & getSelectorFromElement` inside selector-engine.js, in order to use SelectorEngine methods, avoiding raw querySelector usage * add `getMultipleElementsFromSelector` helper Co-authored-by: Julien Déramond <[email protected]>
Diffstat (limited to 'js/src/util/index.js')
-rw-r--r--js/src/util/index.js43
1 files changed, 0 insertions, 43 deletions
diff --git a/js/src/util/index.js b/js/src/util/index.js
index ad99f85ed..b92eddba2 100644
--- a/js/src/util/index.js
+++ b/js/src/util/index.js
@@ -30,47 +30,6 @@ const getUID = prefix => {
return prefix
}
-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 selector
-}
-
-const getSelectorFromElement = element => {
- const selector = getSelector(element)
-
- if (selector) {
- return document.querySelector(selector) ? selector : null
- }
-
- return null
-}
-
-const getElementFromSelector = element => {
- const selector = getSelector(element)
-
- return selector ? document.querySelector(selector) : null
-}
-
const getTransitionDurationFromElement = element => {
if (!element) {
return 0
@@ -316,10 +275,8 @@ export {
executeAfterTransition,
findShadowRoot,
getElement,
- getElementFromSelector,
getjQuery,
getNextActiveElement,
- getSelectorFromElement,
getTransitionDurationFromElement,
getUID,
isDisabled,