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:
parent
79144adb12
commit
f2f69970eb
@ -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)
|
||||
},
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user