From 4cc5f49c5e16bfabe89b58712bdeaa0359394346 Mon Sep 17 00:00:00 2001 From: Andrey Taritsyn Date: Wed, 21 Jun 2017 14:19:24 +0300 Subject: [PATCH] In BundleTransformer.Autoprefixer added a `Array.prototype.fill` polyfill --- .../BundleTransformer.Autoprefixer.nuspec | 2 +- .../BundleTransformer.Autoprefixer/readme.txt | 2 +- .../Resources/autoprefixer-combined.js | 56 +++++++++++++++++++ 3 files changed, 58 insertions(+), 2 deletions(-) diff --git a/NuGet/BundleTransformer.Autoprefixer/BundleTransformer.Autoprefixer.nuspec b/NuGet/BundleTransformer.Autoprefixer/BundleTransformer.Autoprefixer.nuspec index 083248eeb..f916f38a6 100644 --- a/NuGet/BundleTransformer.Autoprefixer/BundleTransformer.Autoprefixer.nuspec +++ b/NuGet/BundleTransformer.Autoprefixer/BundleTransformer.Autoprefixer.nuspec @@ -14,7 +14,7 @@ As a JS engine is used the JavaScript Engine Switcher library (https://github.com/Taritsyn/JavaScriptEngineSwitcher). For correct working of this module, you need to install one of the following NuGet packages: JavaScriptEngineSwitcher.Msie (only in the Chakra JsRT modes), JavaScriptEngineSwitcher.V8 or JavaScriptEngineSwitcher.ChakraCore. BundleTransformer.Autoprefixer contains one postprocessor-adapter for postprocessing of CSS code - `AutoprefixCssPostProcessor`. `AutoprefixCssPostProcessor` is based on the Andrey Sitnik's Autoprefixer version 7.1.1.2. - Added support of Autoprefixer version 7.1.1.2. + Added a `Array.prototype.fill` polyfill. Copyright (c) 2012-2017 Andrey Taritsyn - http://www.taritsyn.ru en-US BundleTransformer System.Web.Optimization IBundleTransform ASP.NET CSS Bundling Postprocessing Postprocessor Autoprefixer diff --git a/NuGet/BundleTransformer.Autoprefixer/readme.txt b/NuGet/BundleTransformer.Autoprefixer/readme.txt index df5eb214f..4cc8637db 100644 --- a/NuGet/BundleTransformer.Autoprefixer/readme.txt +++ b/NuGet/BundleTransformer.Autoprefixer/readme.txt @@ -22,7 +22,7 @@ ============= RELEASE NOTES ============= - Added support of Autoprefixer version 7.1.1.2. + Added a `Array.prototype.fill` polyfill. ==================== POST-INSTALL ACTIONS diff --git a/src/BundleTransformer.Autoprefixer/Resources/autoprefixer-combined.js b/src/BundleTransformer.Autoprefixer/Resources/autoprefixer-combined.js index 443c80757..6e8a0df03 100644 --- a/src/BundleTransformer.Autoprefixer/Resources/autoprefixer-combined.js +++ b/src/BundleTransformer.Autoprefixer/Resources/autoprefixer-combined.js @@ -1,3 +1,59 @@ +/*! + * Array.prototype.fill polyfill + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill + */ +if (!Array.prototype.hasOwnProperty('fill')) { + var fillMethod = function (value) { + var arr, + length, + start, + relativeStart, + finalStart, + end, + relativeEnd, + finalEnd, + itemIndex + ; + + arr = this; + length = arr.length; + + start = arguments[1]; + relativeStart = parseInt(start, 10) || 0; + finalStart = relativeStart < 0 ? + Math.max(length + relativeStart, 0) + : + Math.min(relativeStart, length) + ; + + end = arguments[2]; + relativeEnd = typeof end !== 'undefined' ? (parseInt(end, 10) || 0) : length; + finalEnd = relativeEnd < 0 ? + Math.max(length + relativeEnd, 0) + : + Math.min(relativeEnd, length) + ; + + itemIndex = finalStart; + + while (itemIndex < finalEnd) { + arr[itemIndex] = value; + itemIndex++; + } + + return arr; + }; + + if (Object.hasOwnProperty('defineProperty')) { + Object.defineProperty(Array.prototype, 'fill', { + value: fillMethod + }); + } + else { + Array.prototype.fill = fillMethod; + } +} + /*! * Math.log2 polyfill * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log2