diff options
Diffstat (limited to 'app/assets/javascripts/extensions/element.js.es6')
-rw-r--r-- | app/assets/javascripts/extensions/element.js.es6 | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/app/assets/javascripts/extensions/element.js.es6 b/app/assets/javascripts/extensions/element.js.es6 new file mode 100644 index 00000000000..afb2f0d6956 --- /dev/null +++ b/app/assets/javascripts/extensions/element.js.es6 @@ -0,0 +1,9 @@ +/* global Element */ +/* eslint-disable consistent-return, max-len */ + +Element.prototype.matches = Element.prototype.matches || Element.prototype.msMatchesSelector; + +Element.prototype.closest = function closest(selector, selectedElement = this) { + if (!selectedElement) return; + return selectedElement.matches(selector) ? selectedElement : Element.prototype.closest(selector, selectedElement.parentElement); +}; |