1
0
Fork 0
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:
Johann 2017-03-19 01:42:11 +01:00 committed by Mark Otto
parent f2f8051285
commit f2f2e39a45

View file

@ -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) {