1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-09-27 05:49:07 +02:00

alert without jquery

This commit is contained in:
Johann-S
2017-08-21 09:11:37 +02:00
committed by XhmikosR
parent 8d34bc136b
commit 0b16c8c6d9
17 changed files with 149 additions and 53 deletions

View File

@@ -0,0 +1,42 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.0.0-beta): dom/selectorEngine.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
const SelectorEngine = {
matches: Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector,
find(selector) {
if (typeof selector !== 'string') {
return null
}
let selectorType = 'querySelectorAll'
if (selector.indexOf('#') === 0) {
selectorType = 'getElementById'
selector = selector.substr(1, selector.length)
}
return document[selectorType](selector)
},
closest(element, selector) {
let ancestor = element
if (!document.documentElement.contains(element)) {
return null
}
do {
if (SelectorEngine.matches.call(ancestor, selector)) {
return ancestor
}
ancestor = ancestor.parentElement
} while (ancestor !== null)
return null
}
}
export default SelectorEngine