0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-01-18 10:52:19 +01:00

Add findOne to our SelectorEngine

This commit is contained in:
Johann-S 2017-08-26 12:44:26 +02:00 committed by XhmikosR
parent 79144adb12
commit f2f69970eb

View File

@ -51,11 +51,24 @@ const SelectorEngine = {
return null
}
let selectorType = 'querySelectorAll'
if (selector.indexOf('#') === 0) {
return SelectorEngine.findOne(element, selector)
}
return element.querySelectorAll(selector)
},
findOne(element = document, selector) {
if (typeof selector !== 'string') {
return null
}
let selectorType = 'querySelector'
if (selector.indexOf('#') === 0) {
selectorType = 'getElementById'
selector = selector.substr(1, selector.length)
}
return element[selectorType](selector)
},