summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/extensions/element.js.es6
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/extensions/element.js.es6')
-rw-r--r--app/assets/javascripts/extensions/element.js.es69
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);
+};