Blame rubygem-uglifier-3.0.0-unbundle-js-files-for-jscript.patch

1b290f5
From b023cc8166705f8a2c8b8d348ef5d9a663afbb5f Mon Sep 17 00:00:00 2001
1b290f5
From: Jun Aruga <jaruga@redhat.com>
1b290f5
Date: Wed, 27 Jul 2016 14:30:02 +0200
1b290f5
Subject: [PATCH] Remove JS files for JS Engine not supporting ECMAScript 5.
1b290f5
1b290f5
---
1b290f5
 lib/es5.js      | 321 --------------------------------------------------------
1b290f5
 lib/split.js    | 117 ---------------------
1b290f5
 lib/uglifier.rb |   6 +-
1b290f5
 3 files changed, 1 insertion(+), 443 deletions(-)
1b290f5
 delete mode 100644 lib/es5.js
1b290f5
 delete mode 100644 lib/split.js
1b290f5
1b290f5
diff --git a/lib/es5.js b/lib/es5.js
1b290f5
deleted file mode 100644
1b290f5
index b5712b8..0000000
1b290f5
--- a/lib/es5.js
1b290f5
+++ /dev/null
1b290f5
@@ -1,321 +0,0 @@
1b290f5
-// https://developer.mozilla.org/en/JavaScript/Reference/global_objects/array/foreach
1b290f5
-
1b290f5
-if (!Array.prototype.forEach)
1b290f5
-{
1b290f5
-  Array.prototype.forEach = function(fun /*, thisp */)
1b290f5
-  {
1b290f5
-    "use strict";
1b290f5
-
1b290f5
-    if (this === void 0 || this === null)
1b290f5
-      throw new TypeError();
1b290f5
-
1b290f5
-    var t = Object(this);
1b290f5
-    var len = t.length >>> 0;
1b290f5
-    if (typeof fun !== "function")
1b290f5
-      throw new TypeError();
1b290f5
-
1b290f5
-    var thisp = arguments[1];
1b290f5
-    for (var i = 0; i < len; i++)
1b290f5
-    {
1b290f5
-      if (i in t)
1b290f5
-        fun.call(thisp, t[i], i, t);
1b290f5
-    }
1b290f5
-  };
1b290f5
-}
1b290f5
-
1b290f5
-// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map
1b290f5
-// Production steps of ECMA-262, Edition 5, 15.4.4.19
1b290f5
-// Reference: http://es5.github.com/#x15.4.4.19
1b290f5
-if (!Array.prototype.map) {
1b290f5
-  Array.prototype.map = function(callback, thisArg) {
1b290f5
-
1b290f5
-    var T, A, k;
1b290f5
-
1b290f5
-    if (this == null) {
1b290f5
-      throw new TypeError(" this is null or not defined");
1b290f5
-    }
1b290f5
-
1b290f5
-    // 1. Let O be the result of calling ToObject passing the |this| value as the argument.
1b290f5
-    var O = Object(this);
1b290f5
-
1b290f5
-    // 2. Let lenValue be the result of calling the Get internal method of O with the argument "length".
1b290f5
-    // 3. Let len be ToUint32(lenValue).
1b290f5
-    var len = O.length >>> 0;
1b290f5
-
1b290f5
-    // 4. If IsCallable(callback) is false, throw a TypeError exception.
1b290f5
-    // See: http://es5.github.com/#x9.11
1b290f5
-    if ({}.toString.call(callback) != "[object Function]") {
1b290f5
-      throw new TypeError(callback + " is not a function");
1b290f5
-    }
1b290f5
-
1b290f5
-    // 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
1b290f5
-    if (thisArg) {
1b290f5
-      T = thisArg;
1b290f5
-    }
1b290f5
-
1b290f5
-    // 6. Let A be a new array created as if by the expression new Array(len) where Array is
1b290f5
-    // the standard built-in constructor with that name and len is the value of len.
1b290f5
-    A = new Array(len);
1b290f5
-
1b290f5
-    // 7. Let k be 0
1b290f5
-    k = 0;
1b290f5
-
1b290f5
-    // 8. Repeat, while k < len
1b290f5
-    while(k < len) {
1b290f5
-
1b290f5
-      var kValue, mappedValue;
1b290f5
-
1b290f5
-      // a. Let Pk be ToString(k).
1b290f5
-      //   This is implicit for LHS operands of the in operator
1b290f5
-      // b. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk.
1b290f5
-      //   This step can be combined with c
1b290f5
-      // c. If kPresent is true, then
1b290f5
-      if (k in O) {
1b290f5
-
1b290f5
-        // i. Let kValue be the result of calling the Get internal method of O with argument Pk.
1b290f5
-        kValue = O[ k ];
1b290f5
-
1b290f5
-        // ii. Let mappedValue be the result of calling the Call internal method of callback
1b290f5
-        // with T as the this value and argument list containing kValue, k, and O.
1b290f5
-        mappedValue = callback.call(T, kValue, k, O);
1b290f5
-
1b290f5
-        // iii. Call the DefineOwnProperty internal method of A with arguments
1b290f5
-        // Pk, Property Descriptor {Value: mappedValue, Writable: true, Enumerable: true, Configurable: true},
1b290f5
-        // and false.
1b290f5
-
1b290f5
-        // In browsers that support Object.defineProperty, use the following:
1b290f5
-        // Object.defineProperty(A, Pk, { value: mappedValue, writable: true, enumerable: true, configurable: true });
1b290f5
-
1b290f5
-        // For best browser support, use the following:
1b290f5
-        A[ k ] = mappedValue;
1b290f5
-      }
1b290f5
-      // d. Increase k by 1.
1b290f5
-      k++;
1b290f5
-    }
1b290f5
-
1b290f5
-    // 9. return A
1b290f5
-    return A;
1b290f5
-  };
1b290f5
-}
1b290f5
-
1b290f5
-// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/Reduce
1b290f5
-
1b290f5
-if (!Array.prototype.reduce)
1b290f5
-{
1b290f5
-  Array.prototype.reduce = function(fun /*, initialValue */)
1b290f5
-  {
1b290f5
-    "use strict";
1b290f5
-
1b290f5
-    if (this === void 0 || this === null)
1b290f5
-      throw new TypeError();
1b290f5
-
1b290f5
-    var t = Object(this);
1b290f5
-    var len = t.length >>> 0;
1b290f5
-    if (typeof fun !== "function")
1b290f5
-      throw new TypeError();
1b290f5
-
1b290f5
-    // no value to return if no initial value and an empty array
1b290f5
-    if (len == 0 && arguments.length == 1)
1b290f5
-      throw new TypeError();
1b290f5
-
1b290f5
-    var k = 0;
1b290f5
-    var accumulator;
1b290f5
-    if (arguments.length >= 2)
1b290f5
-    {
1b290f5
-      accumulator = arguments[1];
1b290f5
-    }
1b290f5
-    else
1b290f5
-    {
1b290f5
-      do
1b290f5
-      {
1b290f5
-        if (k in t)
1b290f5
-        {
1b290f5
-          accumulator = t[k++];
1b290f5
-          break;
1b290f5
-        }
1b290f5
-
1b290f5
-        // if array contains no values, no initial value to return
1b290f5
-        if (++k >= len)
1b290f5
-          throw new TypeError();
1b290f5
-      }
1b290f5
-      while (true);
1b290f5
-    }
1b290f5
-
1b290f5
-    while (k < len)
1b290f5
-    {
1b290f5
-      if (k in t)
1b290f5
-        accumulator = fun.call(undefined, accumulator, t[k], k, t);
1b290f5
-      k++;
1b290f5
-    }
1b290f5
-
1b290f5
-    return accumulator;
1b290f5
-  };
1b290f5
-}
1b290f5
-
1b290f5
-// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
1b290f5
-if (!Array.prototype.indexOf) {
1b290f5
-    Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) {
1b290f5
-        "use strict";
1b290f5
-        if (this === void 0 || this === null) {
1b290f5
-            throw new TypeError();
1b290f5
-        }
1b290f5
-        var t = Object(this);
1b290f5
-        var len = t.length >>> 0;
1b290f5
-        if (len === 0) {
1b290f5
-            return -1;
1b290f5
-        }
1b290f5
-        var n = 0;
1b290f5
-        if (arguments.length > 0) {
1b290f5
-            n = Number(arguments[1]);
1b290f5
-            if (n !== n) { // shortcut for verifying if it's NaN
1b290f5
-                n = 0;
1b290f5
-            } else if (n !== 0 && n !== Infinity && n !== -Infinity) {
1b290f5
-                n = (n > 0 || -1) * Math.floor(Math.abs(n));
1b290f5
-            }
1b290f5
-        }
1b290f5
-        if (n >= len) {
1b290f5
-            return -1;
1b290f5
-        }
1b290f5
-        var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0);
1b290f5
-        for (; k < len; k++) {
1b290f5
-            if (k in t && t[k] === searchElement) {
1b290f5
-                return k;
1b290f5
-            }
1b290f5
-        }
1b290f5
-        return -1;
1b290f5
-    }
1b290f5
-}
1b290f5
-
1b290f5
-// https://developer.mozilla.org/en/docs/JavaScript/Reference/Global_Objects/Object/keys
1b290f5
-if (!Object.keys) {
1b290f5
-  Object.keys = (function () {
1b290f5
-    var hasOwnProperty = Object.prototype.hasOwnProperty,
1b290f5
-        hasDontEnumBug = !({toString: null}).propertyIsEnumerable('toString'),
1b290f5
-        dontEnums = [
1b290f5
-          'toString',
1b290f5
-          'toLocaleString',
1b290f5
-          'valueOf',
1b290f5
-          'hasOwnProperty',
1b290f5
-          'isPrototypeOf',
1b290f5
-          'propertyIsEnumerable',
1b290f5
-          'constructor'
1b290f5
-        ],
1b290f5
-        dontEnumsLength = dontEnums.length;
1b290f5
-
1b290f5
-    return function (obj) {
1b290f5
-      if (typeof obj !== 'object' && typeof obj !== 'function' || obj === null) throw new TypeError('Object.keys called on non-object');
1b290f5
-
1b290f5
-      var result = [];
1b290f5
-
1b290f5
-      for (var prop in obj) {
1b290f5
-        if (hasOwnProperty.call(obj, prop)) result.push(prop);
1b290f5
-      }
1b290f5
-
1b290f5
-      if (hasDontEnumBug) {
1b290f5
-        for (var i=0; i < dontEnumsLength; i++) {
1b290f5
-          if (hasOwnProperty.call(obj, dontEnums[i])) result.push(dontEnums[i]);
1b290f5
-        }
1b290f5
-      }
1b290f5
-      return result;
1b290f5
-    }
1b290f5
-  })()
1b290f5
-};
1b290f5
-
1b290f5
-// https://developer.mozilla.org/en/docs/JavaScript/Reference/Global_Objects/Object/create
1b290f5
-if (!Object.create) {
1b290f5
-    Object.create = function (o) {
1b290f5
-        if (arguments.length > 1) {
1b290f5
-            throw new Error('Object.create implementation only accepts the first parameter.');
1b290f5
-        }
1b290f5
-        function F() {}
1b290f5
-        F.prototype = o;
1b290f5
-        return new F();
1b290f5
-    };
1b290f5
-}
1b290f5
-
1b290f5
-// https://developer.mozilla.org/en/docs/JavaScript/Reference/Global_Objects/Array/filter
1b290f5
-if (!Array.prototype.filter)
1b290f5
-{
1b290f5
-  Array.prototype.filter = function(fun /*, thisp*/)
1b290f5
-  {
1b290f5
-    "use strict";
1b290f5
-
1b290f5
-    if (this == null)
1b290f5
-      throw new TypeError();
1b290f5
-
1b290f5
-    var t = Object(this);
1b290f5
-    var len = t.length >>> 0;
1b290f5
-    if (typeof fun != "function")
1b290f5
-      throw new TypeError();
1b290f5
-
1b290f5
-    var res = [];
1b290f5
-    var thisp = arguments[1];
1b290f5
-    for (var i = 0; i < len; i++)
1b290f5
-    {
1b290f5
-      if (i in t)
1b290f5
-      {
1b290f5
-        var val = t[i]; // in case fun mutates this
1b290f5
-        if (fun.call(thisp, val, i, t))
1b290f5
-          res.push(val);
1b290f5
-      }
1b290f5
-    }
1b290f5
-
1b290f5
-    return res;
1b290f5
-  };
1b290f5
-}
1b290f5
-
1b290f5
-// https://developer.mozilla.org/en/docs/JavaScript/Reference/Global_Objects/Function/bind
1b290f5
-if (!Function.prototype.bind) {
1b290f5
-  Function.prototype.bind = function (oThis) {
1b290f5
-    if (typeof this !== "function") {
1b290f5
-      // closest thing possible to the ECMAScript 5 internal IsCallable function
1b290f5
-      throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
1b290f5
-    }
1b290f5
-
1b290f5
-    var aArgs = Array.prototype.slice.call(arguments, 1),
1b290f5
-        fToBind = this,
1b290f5
-        fNOP = function () {},
1b290f5
-        fBound = function () {
1b290f5
-          return fToBind.apply(this instanceof fNOP && oThis
1b290f5
-                                 ? this
1b290f5
-                                 : oThis,
1b290f5
-                               aArgs.concat(Array.prototype.slice.call(arguments)));
1b290f5
-        };
1b290f5
-
1b290f5
-    fNOP.prototype = this.prototype;
1b290f5
-    fBound.prototype = new fNOP();
1b290f5
-
1b290f5
-    return fBound;
1b290f5
-  };
1b290f5
-}
1b290f5
-
1b290f5
-// https://developer.mozilla.org/en/docs/JavaScript/Reference/Global_Objects/Array/isArray
1b290f5
-if(!Array.isArray) {
1b290f5
-  Array.isArray = function (vArg) {
1b290f5
-    return Object.prototype.toString.call(vArg) === "[object Array]";
1b290f5
-  };
1b290f5
-}
1b290f5
-
1b290f5
-// https://developer.mozilla.org/en/docs/JavaScript/Reference/Global_Objects/String/trim
1b290f5
-if(!String.prototype.trim) {
1b290f5
-  String.prototype.trim = function () {
1b290f5
-    return this.replace(/^\s+|\s+$/g,'');
1b290f5
-  };
1b290f5
-}
1b290f5
-
1b290f5
-
1b290f5
-function definePropertyWorks() {
1b290f5
-  try {
1b290f5
-    Object.defineProperty({}, "property", {});
1b290f5
-    return true;
1b290f5
-  } catch (exception) {
1b290f5
-    return false;
1b290f5
-  }
1b290f5
-}
1b290f5
-
1b290f5
-if (!definePropertyWorks()) {
1b290f5
-  Object.defineProperty = function defineProperty(object) {
1b290f5
-    // fail silently
1b290f5
-    return object;
1b290f5
-  }
1b290f5
-}
1b290f5
diff --git a/lib/split.js b/lib/split.js
1b290f5
deleted file mode 100644
1b290f5
index 8cc2924..0000000
1b290f5
--- a/lib/split.js
1b290f5
+++ /dev/null
1b290f5
@@ -1,117 +0,0 @@
1b290f5
-/*!
1b290f5
- * Cross-Browser Split 1.1.1
1b290f5
- * Copyright 2007-2012 Steven Levithan <stevenlevithan.com>
1b290f5
- * Available under the MIT License
1b290f5
- * ECMAScript compliant, uniform cross-browser split method
1b290f5
- */
1b290f5
-
1b290f5
-/**
1b290f5
- * Splits a string into an array of strings using a regex or string separator. Matches of the
1b290f5
- * separator are not included in the result array. However, if `separator` is a regex that contains
1b290f5
- * capturing groups, backreferences are spliced into the result each time `separator` is matched.
1b290f5
- * Fixes browser bugs compared to the native `String.prototype.split` and can be used reliably
1b290f5
- * cross-browser.
1b290f5
- * @param {String} str String to split.
1b290f5
- * @param {RegExp|String} separator Regex or string to use for separating the string.
1b290f5
- * @param {Number} [limit] Maximum number of items to include in the result array.
1b290f5
- * @returns {Array} Array of substrings.
1b290f5
- * @example
1b290f5
- *
1b290f5
- * // Basic use
1b290f5
- * split('a b c d', ' ');
1b290f5
- * // -> ['a', 'b', 'c', 'd']
1b290f5
- *
1b290f5
- * // With limit
1b290f5
- * split('a b c d', ' ', 2);
1b290f5
- * // -> ['a', 'b']
1b290f5
- *
1b290f5
- * // Backreferences in result array
1b290f5
- * split('..word1 word2..', /([a-z]+)(\d+)/i);
1b290f5
- * // -> ['..', 'word', '1', ' ', 'word', '2', '..']
1b290f5
- */
1b290f5
-var split;
1b290f5
-
1b290f5
-// Avoid running twice; that would break the `nativeSplit` reference
1b290f5
-split = split || function (undef) {
1b290f5
-
1b290f5
-    var nativeSplit = String.prototype.split,
1b290f5
-        compliantExecNpcg = /()??/.exec("")[1] === undef, // NPCG: nonparticipating capturing group
1b290f5
-        self;
1b290f5
-
1b290f5
-    self = function (str, separator, limit) {
1b290f5
-        // If `separator` is not a regex, use `nativeSplit`
1b290f5
-        if (Object.prototype.toString.call(separator) !== "[object RegExp]") {
1b290f5
-            return nativeSplit.call(str, separator, limit);
1b290f5
-        }
1b290f5
-        var output = [],
1b290f5
-            flags = (separator.ignoreCase ? "i" : "") +
1b290f5
-                    (separator.multiline  ? "m" : "") +
1b290f5
-                    (separator.extended   ? "x" : "") + // Proposed for ES6
1b290f5
-                    (separator.sticky     ? "y" : ""), // Firefox 3+
1b290f5
-            lastLastIndex = 0,
1b290f5
-            // Make `global` and avoid `lastIndex` issues by working with a copy
1b290f5
-            separator = new RegExp(separator.source, flags + "g"),
1b290f5
-            separator2, match, lastIndex, lastLength;
1b290f5
-        str += ""; // Type-convert
1b290f5
-        if (!compliantExecNpcg) {
1b290f5
-            // Doesn't need flags gy, but they don't hurt
1b290f5
-            separator2 = new RegExp("^" + separator.source + "$(?!\\s)", flags);
1b290f5
-        }
1b290f5
-        /* Values for `limit`, per the spec:
1b290f5
-         * If undefined: 4294967295 // Math.pow(2, 32) - 1
1b290f5
-         * If 0, Infinity, or NaN: 0
1b290f5
-         * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;
1b290f5
-         * If negative number: 4294967296 - Math.floor(Math.abs(limit))
1b290f5
-         * If other: Type-convert, then use the above rules
1b290f5
-         */
1b290f5
-        limit = limit === undef ?
1b290f5
-            -1 >>> 0 : // Math.pow(2, 32) - 1
1b290f5
-            limit >>> 0; // ToUint32(limit)
1b290f5
-        while (match = separator.exec(str)) {
1b290f5
-            // `separator.lastIndex` is not reliable cross-browser
1b290f5
-            lastIndex = match.index + match[0].length;
1b290f5
-            if (lastIndex > lastLastIndex) {
1b290f5
-                output.push(str.slice(lastLastIndex, match.index));
1b290f5
-                // Fix browsers whose `exec` methods don't consistently return `undefined` for
1b290f5
-                // nonparticipating capturing groups
1b290f5
-                if (!compliantExecNpcg && match.length > 1) {
1b290f5
-                    match[0].replace(separator2, function () {
1b290f5
-                        for (var i = 1; i < arguments.length - 2; i++) {
1b290f5
-                            if (arguments[i] === undef) {
1b290f5
-                                match[i] = undef;
1b290f5
-                            }
1b290f5
-                        }
1b290f5
-                    });
1b290f5
-                }
1b290f5
-                if (match.length > 1 && match.index < str.length) {
1b290f5
-                    Array.prototype.push.apply(output, match.slice(1));
1b290f5
-                }
1b290f5
-                lastLength = match[0].length;
1b290f5
-                lastLastIndex = lastIndex;
1b290f5
-                if (output.length >= limit) {
1b290f5
-                    break;
1b290f5
-                }
1b290f5
-            }
1b290f5
-            if (separator.lastIndex === match.index) {
1b290f5
-                separator.lastIndex++; // Avoid an infinite loop
1b290f5
-            }
1b290f5
-        }
1b290f5
-        if (lastLastIndex === str.length) {
1b290f5
-            if (lastLength || !separator.test("")) {
1b290f5
-                output.push("");
1b290f5
-            }
1b290f5
-        } else {
1b290f5
-            output.push(str.slice(lastLastIndex));
1b290f5
-        }
1b290f5
-        return output.length > limit ? output.slice(0, limit) : output;
1b290f5
-    };
1b290f5
-
1b290f5
-    if ("\n".split(/\n/).length == 0) {
1b290f5
-        String.prototype.split = function (separator, limit) {
1b290f5
-            return self(this, separator, limit);
1b290f5
-        };
1b290f5
-    }
1b290f5
-
1b290f5
-    return self;
1b290f5
-
1b290f5
-}();
1b290f5
diff --git a/lib/uglifier.rb b/lib/uglifier.rb
1b290f5
index de24e26..431c4b3 100644
1b290f5
--- a/lib/uglifier.rb
1b290f5
+++ b/lib/uglifier.rb
1b290f5
@@ -14,10 +14,6 @@ class Uglifier
1b290f5
   SourcePath = File.expand_path("../uglify.js", __FILE__)
1b290f5
   # Source Map path
1b290f5
   SourceMapPath = File.expand_path("../source-map.js", __FILE__)
1b290f5
-  # ES5 shims source path
1b290f5
-  ES5FallbackPath = File.expand_path("../es5.js", __FILE__)
1b290f5
-  # String.split shim source path
1b290f5
-  SplitFallbackPath = File.expand_path("../split.js", __FILE__)
1b290f5
   # UglifyJS wrapper path
1b290f5
   UglifyJSWrapperPath = File.expand_path("../uglifier.js", __FILE__)
1b290f5
 
1b290f5
@@ -154,7 +150,7 @@ class Uglifier
1b290f5
   private
1b290f5
 
1b290f5
   def uglifyjs_source
1b290f5
-    [ES5FallbackPath, SplitFallbackPath, SourceMapPath, SourcePath,
1b290f5
+    [SourceMapPath, SourcePath,
1b290f5
      UglifyJSWrapperPath].map do |file|
1b290f5
       File.open(file, "r:UTF-8", &:read)
1b290f5
     end.join("\n")
1b290f5
-- 
1b290f5
2.5.5
1b290f5