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

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