Skip to content

Commit

Permalink
Removing matches polyfill from closest polyfill (#286)
Browse files Browse the repository at this point in the history
  • Loading branch information
ygongdev committed Oct 6, 2019
1 parent cc39031 commit b96d320
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions vendor/polyfills/closest.js
Expand Up @@ -2,32 +2,12 @@
// https://github.com/jonathantneal/closest
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
(function(ElementProto) {
if (typeof ElementProto.matches !== 'function') {
ElementProto.matches =
ElementProto.msMatchesSelector ||
ElementProto.mozMatchesSelector ||
ElementProto.webkitMatchesSelector ||
function matches(selector) {
var element = this;
var elements = (
element.document || element.ownerDocument
).querySelectorAll(selector);
var index = 0;

while (elements[index] && elements[index] !== element) {
++index;
}

return Boolean(elements[index]);
};
}

if (typeof ElementProto.closest !== 'function') {
ElementProto.closest = function closest(selector) {
var element = this;

while (element && element.nodeType === 1) {
if (element.matches(selector)) {
if (element.msMatchesSelector(selector)) {
return element;
}

Expand Down

0 comments on commit b96d320

Please sign in to comment.