mirror of
https://github.com/twbs/bootstrap.git
synced 2022-11-09 12:25:43 -05:00
Fix getSelectorFromElement when # is a selector (#21615)
* Fix getSelectorFromElement when # is a selector * Thanks to @vanduynslagerp remove regex to validate selector
This commit is contained in:
parent
f2f8051285
commit
f2f2e39a45
1 changed files with 7 additions and 4 deletions
|
@ -112,13 +112,16 @@ const Util = (($) => {
|
||||||
|
|
||||||
getSelectorFromElement(element) {
|
getSelectorFromElement(element) {
|
||||||
let selector = element.getAttribute('data-target')
|
let selector = element.getAttribute('data-target')
|
||||||
|
if (!selector || selector === '#') {
|
||||||
if (!selector) {
|
|
||||||
selector = element.getAttribute('href') || ''
|
selector = element.getAttribute('href') || ''
|
||||||
selector = /^#[a-z]/i.test(selector) ? selector : null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return selector
|
try {
|
||||||
|
const $selector = $(selector)
|
||||||
|
return $selector.length > 0 ? selector : null
|
||||||
|
} catch (error) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
reflow(element) {
|
reflow(element) {
|
||||||
|
|
Loading…
Reference in a new issue