diff options
Diffstat (limited to 'app/assets/javascripts/commons/polyfills')
6 files changed, 0 insertions, 166 deletions
diff --git a/app/assets/javascripts/commons/polyfills/custom_event.js b/app/assets/javascripts/commons/polyfills/custom_event.js deleted file mode 100644 index 6b14eff6f05..00000000000 --- a/app/assets/javascripts/commons/polyfills/custom_event.js +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Polyfill: CustomEvent constructor - * @what new CustomEvent() - * @why Certain features, e.g. notes utilize this - * @browsers Internet Explorer 11 - * @see https://caniuse.com/#feat=customevent - */ -if (typeof window.CustomEvent !== 'function') { - window.CustomEvent = function CustomEvent(event, params) { - const evt = document.createEvent('CustomEvent'); - const evtParams = { - bubbles: false, - cancelable: false, - detail: undefined, - ...params, - }; - evt.initCustomEvent(event, evtParams.bubbles, evtParams.cancelable, evtParams.detail); - return evt; - }; - window.CustomEvent.prototype = Event; -} diff --git a/app/assets/javascripts/commons/polyfills/element.js b/app/assets/javascripts/commons/polyfills/element.js deleted file mode 100644 index b13ceccf511..00000000000 --- a/app/assets/javascripts/commons/polyfills/element.js +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Polyfill - * @what Element.classList - * @why In order to align browser features - * @browsers Internet Explorer 11 - * @see https://caniuse.com/#feat=classlist - */ -import 'classlist-polyfill'; - -/** - * Polyfill - * @what Element.closest - * @why In order to align browser features - * @browsers Internet Explorer 11 - * @see https://caniuse.com/#feat=element-closest - */ -Element.prototype.closest = - Element.prototype.closest || - function closest(selector, selectedElement = this) { - if (!selectedElement) return null; - return selectedElement.matches(selector) - ? selectedElement - : Element.prototype.closest(selector, selectedElement.parentElement); - }; - -/** - * Polyfill - * @what Element.matches - * @why In order to align browser features - * @browsers Internet Explorer 11 - * @see https://caniuse.com/#feat=mdn-api_element_matches - */ -Element.prototype.matches = - Element.prototype.matches || - Element.prototype.matchesSelector || - Element.prototype.mozMatchesSelector || - Element.prototype.msMatchesSelector || - Element.prototype.oMatchesSelector || - Element.prototype.webkitMatchesSelector || - function matches(selector) { - const elms = (this.document || this.ownerDocument).querySelectorAll(selector); - let i = elms.length - 1; - while (i >= 0 && elms.item(i) !== this) { - i -= 1; - } - return i > -1; - }; - -/** - * Polyfill - * @what ChildNode.remove, Element.remove, CharacterData.remove, DocumentType.remove - * @why In order to align browser features - * @browsers Internet Explorer 11 - * @see https://caniuse.com/#feat=childnode-remove - * - * From the polyfill on MDN, https://developer.mozilla.org/en-US/docs/Web/API/ChildNode/remove#Polyfill - */ -(arr => { - arr.forEach(item => { - if (Object.prototype.hasOwnProperty.call(item, 'remove')) { - return; - } - Object.defineProperty(item, 'remove', { - configurable: true, - enumerable: true, - writable: true, - value: function remove() { - if (this.parentNode !== null) { - this.parentNode.removeChild(this); - } - }, - }); - }); -})([Element.prototype, CharacterData.prototype, DocumentType.prototype]); diff --git a/app/assets/javascripts/commons/polyfills/event.js b/app/assets/javascripts/commons/polyfills/event.js deleted file mode 100644 index 543dd5f9a93..00000000000 --- a/app/assets/javascripts/commons/polyfills/event.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Polyfill: Event constructor - * @what new Event() - * @why To align browser support - * @browsers Internet Explorer 11 - * @see https://caniuse.com/#feat=mdn-api_event_event - * - * Although `initEvent` is deprecated for modern browsers it is the one supported by IE - */ -if (typeof window.Event !== 'function') { - window.Event = function Event(event, params) { - const evt = document.createEvent('Event'); - const evtParams = { - bubbles: false, - cancelable: false, - ...params, - }; - evt.initEvent(event, evtParams.bubbles, evtParams.cancelable); - return evt; - }; - window.Event.prototype = Event; -} diff --git a/app/assets/javascripts/commons/polyfills/nodelist.js b/app/assets/javascripts/commons/polyfills/nodelist.js deleted file mode 100644 index 3a9111e64f8..00000000000 --- a/app/assets/javascripts/commons/polyfills/nodelist.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Polyfill - * @what NodeList.forEach - * @why To align browser support - * @browsers Internet Explorer 11 - * @see https://caniuse.com/#feat=mdn-api_nodelist_foreach - */ -if (window.NodeList && !NodeList.prototype.forEach) { - NodeList.prototype.forEach = function forEach(callback, thisArg = window) { - for (let i = 0; i < this.length; i += 1) { - callback.call(thisArg, this[i], i, this); - } - }; -} diff --git a/app/assets/javascripts/commons/polyfills/request_idle_callback.js b/app/assets/javascripts/commons/polyfills/request_idle_callback.js deleted file mode 100644 index 51dc82e593a..00000000000 --- a/app/assets/javascripts/commons/polyfills/request_idle_callback.js +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Polyfill - * @what requestIdleCallback - * @why To align browser features - * @browsers Safari (all versions), Internet Explorer 11 - * @see https://caniuse.com/#feat=requestidlecallback - */ -window.requestIdleCallback = - window.requestIdleCallback || - function requestShim(cb) { - const start = Date.now(); - return setTimeout(() => { - cb({ - didTimeout: false, - timeRemaining: () => Math.max(0, 50 - (Date.now() - start)), - }); - }, 1); - }; - -window.cancelIdleCallback = - window.cancelIdleCallback || - function cancelShim(id) { - clearTimeout(id); - }; diff --git a/app/assets/javascripts/commons/polyfills/svg.js b/app/assets/javascripts/commons/polyfills/svg.js deleted file mode 100644 index 92a8b03fbb4..00000000000 --- a/app/assets/javascripts/commons/polyfills/svg.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * polyfill support for external SVG file references via <use xlink:href> - * @what polyfill support for external SVG file references via <use xlink:href> - * @why This is used in our GitLab SVG icon library - * @browsers Internet Explorer 11 - * @see https://caniuse.com/#feat=mdn-svg_elements_use_external_uri - * @see https//css-tricks.com/svg-use-external-source/ - */ -import svg4everybody from 'svg4everybody'; - -svg4everybody(); |