Skip to content

Commit

Permalink
Add back support for closest for supporting browsers
Browse files Browse the repository at this point in the history
  • Loading branch information
ten1seven committed Mar 27, 2019
1 parent 1229446 commit 93335ed
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 16 deletions.
2 changes: 1 addition & 1 deletion dist/maps/what-input.min.js.map

Large diffs are not rendered by default.

22 changes: 15 additions & 7 deletions dist/what-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,15 +409,23 @@ return /******/ (function(modules) { // webpackBootstrap

// manual version of `closest()`
var checkClosest = function checkClosest(elem, tag) {
do {
if (elem.matches(tag)) {
return elem;
}
if (!Element.prototype.matches) {
Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
}

if (!Element.prototype.closest) {
do {
if (elem.matches(tag)) {
return elem;
}

elem = elem.parentElement || elem.parentNode;
} while (elem !== null && elem.nodeType === 1);
elem = elem.parentElement || elem.parentNode;
} while (elem !== null && elem.nodeType === 1);

return null;
return null;
} else {
return elem.closest(tag);
}
};

/*
Expand Down
2 changes: 1 addition & 1 deletion dist/what-input.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 15 additions & 7 deletions src/scripts/what-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,15 +368,23 @@ module.exports = (() => {

// manual version of `closest()`
const checkClosest = (elem, tag) => {
do {
if (elem.matches(tag)) {
return elem
}
if (!Element.prototype.matches) {
Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector
}

if (!Element.prototype.closest) {
do {
if (elem.matches(tag)) {
return elem
}

elem = elem.parentElement || elem.parentNode
} while (elem !== null && elem.nodeType === 1)
elem = elem.parentElement || elem.parentNode
} while (elem !== null && elem.nodeType === 1)

return null;
return null
} else {
return elem.closest(tag)
}
}

/*
Expand Down

0 comments on commit 93335ed

Please sign in to comment.