Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'content/assets/javascripts/closest-polyfill.js')
-rw-r--r--content/assets/javascripts/closest-polyfill.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/content/assets/javascripts/closest-polyfill.js b/content/assets/javascripts/closest-polyfill.js
new file mode 100644
index 00000000..6a10a113
--- /dev/null
+++ b/content/assets/javascripts/closest-polyfill.js
@@ -0,0 +1,19 @@
+/*
+ * Polyfill for browsers that do not support Element.closest()
+ */
+if (!Element.prototype.matches) {
+ Element.prototype.matches = Element.prototype.msMatchesSelector ||
+ Element.prototype.webkitMatchesSelector;
+}
+
+if (!Element.prototype.closest) {
+ Element.prototype.closest = function(s) {
+ var el = this;
+
+ do {
+ if (el.matches(s)) return el;
+ el = el.parentElement || el.parentNode;
+ } while (el !== null && el.nodeType === 1);
+ return null;
+ };
+}