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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2016-11-25 15:13:12 +0300
committerFilipa Lacerda <filipa@gitlab.com>2016-11-30 20:06:47 +0300
commitcb9cee545a5952ed35ccd95e8cd4abe228f09a7b (patch)
tree04d7c96e23232f82863ae18f7f4bf57435b30024 /app/assets/javascripts/extensions
parent58d6120a3b9b5d38566766b7e0154010c6a00bd5 (diff)
Adds .matches polyfill
Moves matches poly to the correct file Divides pipelines index and show tests in order to be able to test with JS
Diffstat (limited to 'app/assets/javascripts/extensions')
-rw-r--r--app/assets/javascripts/extensions/element.js.es625
1 files changed, 23 insertions, 2 deletions
diff --git a/app/assets/javascripts/extensions/element.js.es6 b/app/assets/javascripts/extensions/element.js.es6
index 6d9b0c4bc3e..0abe8644f30 100644
--- a/app/assets/javascripts/extensions/element.js.es6
+++ b/app/assets/javascripts/extensions/element.js.es6
@@ -1,9 +1,30 @@
/* global Element */
/* eslint-disable consistent-return, max-len */
-Element.prototype.matches = Element.prototype.matches || Element.prototype.msMatchesSelector;
-
Element.prototype.closest = Element.prototype.closest || function closest(selector, selectedElement = this) {
if (!selectedElement) return;
return selectedElement.matches(selector) ? selectedElement : Element.prototype.closest(selector, selectedElement.parentElement);
};
+
+/* eslint-disable */
+/**
+ * .matches polyfill from mdn
+ * https://developer.mozilla.org/en-US/docs/Web/API/Element/matches
+ *
+ * .matches is used in our code.
+ * In order to run the tests in Phantomjs we need this polyfill
+ */
+if (!Element.prototype.matches) {
+ Element.prototype.matches =
+ Element.prototype.matchesSelector ||
+ Element.prototype.mozMatchesSelector ||
+ Element.prototype.msMatchesSelector ||
+ Element.prototype.oMatchesSelector ||
+ Element.prototype.webkitMatchesSelector ||
+ function (s) {
+ var matches = (this.document || this.ownerDocument).querySelectorAll(s),
+ i = matches.length;
+ while (--i >= 0 && matches.item(i) !== this) {}
+ return i > -1;
+ };
+}