From e6a0414c10a14546a4afd7f49ced73c2f53d8576 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Sun, 3 Apr 2022 18:03:28 +0200 Subject: [PATCH] theme: even more JS IE11 fixing --- static/js/theme.js | 12 ------------ static/js/variant.js | 22 +++++++++++++++++++--- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/static/js/theme.js b/static/js/theme.js index c53e5941c8..ce9d9c1608 100644 --- a/static/js/theme.js +++ b/static/js/theme.js @@ -3,18 +3,6 @@ var isIE = /*@cc_on!@*/false || !!document.documentMode; if( isIE ){ // we don't support sidebar flyout in IE document.querySelector( 'body' ).classList.remove( 'mobile-support' ); - // polyfill this rotten piece of sh...oftware - if( typeof NodeList !== "undefined" && NodeList.prototype && !NodeList.prototype.forEach ){ - NodeList.prototype.forEach = Array.prototype.forEach; - } - if (!String.prototype.startsWith) { - Object.defineProperty(String.prototype, 'startsWith', { - value: function(search, rawPos) { - var pos = rawPos > 0 ? rawPos|0 : 0; - return this.substring(pos, pos + search.length) === search; - } - }); - } } else{ document.querySelector( 'body' ).classList.add( 'mobile-support' ); diff --git a/static/js/variant.js b/static/js/variant.js index 164fe61425..a7f52ddb35 100644 --- a/static/js/variant.js +++ b/static/js/variant.js @@ -1,8 +1,24 @@ -// MDN Array.from Polyfill; Production steps of ECMA-262, Edition 6, 22.1.2.1 -Array.from||(Array.from=function(){var r;try{r=Symbol.iterator?Symbol.iterator:"Symbol(Symbol.iterator)"}catch(t){r="Symbol(Symbol.iterator)"}var t=Object.prototype.toString,n=function(r){return"function"==typeof r||"[object Function]"===t.call(r)},o=Math.pow(2,53)-1,e=function(r){var t=function(r){var t=Number(r);return isNaN(t)?0:0!==t&&isFinite(t)?(t>0?1:-1)*Math.floor(Math.abs(t)):t}(r);return Math.min(Math.max(t,0),o)},a=function(t,n){var o=t&&n[r]();return function(r){return t?o.next():n[r]}},i=function(r,t,n,o,e,a){for(var i=0;i1?arguments[1]:void 0;if(void 0!==c){if(!n(c))throw new TypeError("Array.from: when provided, the second argument must be a function");arguments.length>2&&(l=arguments[2])}var y=e(u.length),h=n(o)?Object(new o(y)):new Array(y);return i(l,h,y,a(f,u),f,c)}}()); - // we need to load this script in the html head to avoid flickering // on page load if the user has selected a non default variant + +// polyfill this rotten piece of sh...oftware +if( typeof NodeList !== "undefined" && NodeList.prototype && !NodeList.prototype.forEach ){ + NodeList.prototype.forEach = Array.prototype.forEach; +} + +if (!String.prototype.startsWith) { + Object.defineProperty(String.prototype, 'startsWith', { + value: function(search, rawPos) { + var pos = rawPos > 0 ? rawPos|0 : 0; + return this.substring(pos, pos + search.length) === search; + } + }); +} + +if(!Array.prototype.find){Array.prototype.find=function(predicate){if(this===null){throw new TypeError('Array.prototype.find called on null or undefined')}if(typeof predicate!=='function'){throw new TypeError('predicate must be a function')}var list=Object(this);var length=list.length>>>0;var thisArg=arguments[1];var value;for(var i=0;i0?1:-1)*Math.floor(Math.abs(t)):t}(r);return Math.min(Math.max(t,0),o)},a=function(t,n){var o=t&&n[r]();return function(r){return t?o.next():n[r]}},i=function(r,t,n,o,e,a){for(var i=0;i1?arguments[1]:void 0;if(void 0!==c){if(!n(c))throw new TypeError("Array.from: when provided, the second argument must be a function");arguments.length>2&&(l=arguments[2])}var y=e(u.length),h=n(o)?Object(new o(y)):new Array(y);return i(l,h,y,a(f,u),f,c)}}()); + function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }