Created
June 19, 2019 06:12
-
-
Save DevCodo/e98be58b0748e40abb7cf497f3311135 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function() { | |
| if (!Element.prototype.matches) { | |
| // определяем свойство | |
| Element.prototype.matches = Element.prototype.matchesSelector || | |
| Element.prototype.webkitMatchesSelector || | |
| Element.prototype.mozMatchesSelector || | |
| Element.prototype.msMatchesSelector; | |
| } | |
| // проверяем поддержку | |
| if (!Element.prototype.closest) { | |
| // реализуем | |
| Element.prototype.closest = function(css) { | |
| var node = this; | |
| while (node) { | |
| if (node.matches(css)) return node; | |
| else node = node.parentElement; | |
| } | |
| return null; | |
| }; | |
| } | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment