gitlab-org--gitlab-foss/app/assets/javascripts/extensions/element.js.es6

10 lines
412 B
JavaScript
Raw Normal View History

/* global Element */
/* eslint-disable consistent-return, max-len */
Element.prototype.matches = Element.prototype.matches || Element.prototype.msMatchesSelector;
2016-10-20 17:18:39 -04:00
Element.prototype.closest = function closest(selector, selectedElement = this) {
if (!selectedElement) return;
return selectedElement.matches(selector) ? selectedElement : Element.prototype.closest(selector, selectedElement.parentElement);
};