diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2016-11-25 15:13:12 +0300 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2016-11-30 20:06:47 +0300 |
commit | cb9cee545a5952ed35ccd95e8cd4abe228f09a7b (patch) | |
tree | 04d7c96e23232f82863ae18f7f4bf57435b30024 /app/assets/javascripts/extensions/element.js.es6 | |
parent | 58d6120a3b9b5d38566766b7e0154010c6a00bd5 (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/element.js.es6')
-rw-r--r-- | app/assets/javascripts/extensions/element.js.es6 | 25 |
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; + }; +} |