diff --git a/app/assets/javascripts/polyfills.js b/app/assets/javascripts/polyfills.js index 116b16d77cf..c2f9fd9ec2d 100644 --- a/app/assets/javascripts/polyfills.js +++ b/app/assets/javascripts/polyfills.js @@ -1,24 +1,25 @@ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries if (!Object.entries) { - Object.entries = function( obj ){ - var ownProps = Object.keys( obj ), - i = ownProps.length, - resArray = new Array(i); // preallocate the Array - while (i--) - resArray[i] = [ownProps[i], obj[ownProps[i]]]; + Object.entries = function(obj) { + var ownProps = Object.keys(obj), + i = ownProps.length, + resArray = new Array(i); // preallocate the Array + while (i--) resArray[i] = [ownProps[i], obj[ownProps[i]]]; return resArray; }; } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign -if (typeof Object.assign !== 'function') { +if (typeof Object.assign !== "function") { // Must be writable: true, enumerable: false, configurable: true Object.defineProperty(Object, "assign", { - value: function assign(target) { // .length of function is 2 - 'use strict'; - if (target == null) { // TypeError if undefined or null - throw new TypeError('Cannot convert undefined or null to object'); + value: function assign(target) { + // .length of function is 2 + "use strict"; + if (target == null) { + // TypeError if undefined or null + throw new TypeError("Cannot convert undefined or null to object"); } var to = Object(target); @@ -26,7 +27,8 @@ if (typeof Object.assign !== 'function') { for (var index = 1; index < arguments.length; index++) { var nextSource = arguments[index]; - if (nextSource != null) { // Skip over if undefined or null + if (nextSource != null) { + // Skip over if undefined or null for (var nextKey in nextSource) { // Avoid bugs when hasOwnProperty is shadowed if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) { @@ -45,9 +47,8 @@ if (typeof Object.assign !== 'function') { // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes#Polyfill /* eslint-disable */ if (!Array.prototype.includes) { - Object.defineProperty(Array.prototype, 'includes', { + Object.defineProperty(Array.prototype, "includes", { value: function(searchElement, fromIndex) { - if (this == null) { throw new TypeError('"this" is null or not defined'); } @@ -75,7 +76,13 @@ if (!Array.prototype.includes) { var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0); function sameValueZero(x, y) { - return x === y || (typeof x === 'number' && typeof y === 'number' && isNaN(x) && isNaN(y)); + return ( + x === y || + (typeof x === "number" && + typeof y === "number" && + isNaN(x) && + isNaN(y)) + ); } // 7. Repeat, while k < len @@ -97,26 +104,26 @@ if (!Array.prototype.includes) { // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes#Polyfill if (!String.prototype.includes) { - Object.defineProperty(String.prototype, 'includes', { + Object.defineProperty(String.prototype, "includes", { value: function(search, start) { - if (typeof start !== 'number') { - start = 0 + if (typeof start !== "number") { + start = 0; } if (start + search.length > this.length) { - return false + return false; } else { - return this.indexOf(search, start) !== -1 + return this.indexOf(search, start) !== -1; } } - }) + }); } // https://tc39.github.io/ecma262/#sec-array.prototype.find if (!Array.prototype.find) { - Object.defineProperty(Array.prototype, 'find', { + Object.defineProperty(Array.prototype, "find", { value: function(predicate) { - // 1. Let O be ? ToObject(this value). + // 1. Let O be ? ToObject(this value). if (this == null) { throw new TypeError('"this" is null or not defined'); } @@ -127,8 +134,8 @@ if (!Array.prototype.find) { var len = o.length >>> 0; // 3. If IsCallable(predicate) is false, throw a TypeError exception. - if (typeof predicate !== 'function') { - throw new TypeError('predicate must be a function'); + if (typeof predicate !== "function") { + throw new TypeError("predicate must be a function"); } // 4. If thisArg was supplied, let T be thisArg; else let T be undefined.