first commit
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
export function matches(element, selector) {
|
||||
var nativeMatches = element.matches
|
||||
|| element.webkitMatchesSelector
|
||||
|| element.msMatchesSelector;
|
||||
return nativeMatches.call(element, selector);
|
||||
}
|
||||
export function closest(element, selector) {
|
||||
if (element.closest) {
|
||||
return element.closest(selector);
|
||||
}
|
||||
var el = element;
|
||||
while (el) {
|
||||
if (matches(el, selector)) {
|
||||
return el;
|
||||
}
|
||||
el = el.parentElement;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user