mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 15:27:50 +00:00
Add comment explaining JavaScript engine's arguments.length limit and add shim file to underscore.html.
Former-commit-id: ace6dae609cab05b86ddc60a7f8c980447da2bdc
This commit is contained in:
23
lodash.js
23
lodash.js
@@ -12,12 +12,26 @@
|
||||
var freeExports = typeof exports == 'object' && exports &&
|
||||
(typeof global == 'object' && global && global == global.global && (window = global), exports);
|
||||
|
||||
/** Used to detect the JavaScript engine's argument length limit */
|
||||
var argsLimit = Math.pow(2, 32) - 1;
|
||||
/**
|
||||
* Used to detect the JavaScript engine's argument length limit.
|
||||
*
|
||||
* The initial value of `argsLimit` is low enough not to cause uncatchable
|
||||
* errors in Java and avoid locking up older browsers like Safari 3.
|
||||
*
|
||||
* Some engines have a limit on the number of arguments functions can accept
|
||||
* before clipping the argument length or throwing an error.
|
||||
* https://bugs.webkit.org/show_bug.cgi?id=80797
|
||||
*
|
||||
* For example Firefox's limits have been observed to be at least:
|
||||
* Firefox 2 - 35,535
|
||||
* Firefox 3.6 - 16,777,215
|
||||
* Firefox 4-7 - 523,264
|
||||
* Firefox >= 8 - Throws error
|
||||
*/
|
||||
var argsLimit = 5e4;
|
||||
|
||||
try {
|
||||
// skip test if running in Java to avoid uncatchable error
|
||||
window.environment && environment['java.home'] || (function() {
|
||||
(function() {
|
||||
argsLimit = arguments.length;
|
||||
}).apply(null, Array(argsLimit));
|
||||
} catch(e) { }
|
||||
@@ -1298,7 +1312,6 @@
|
||||
if (array[0] === +array[0] && length <= argsLimit) {
|
||||
// some JavaScript engines have a limit on the number of arguments functions
|
||||
// can accept before clipping the argument length or throwing an error
|
||||
// https://bugs.webkit.org/show_bug.cgi?id=80797
|
||||
try {
|
||||
return Math.max.apply(Math, array);
|
||||
} catch(e) { }
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
<div id="id2"></div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="../vendor/backbone/test/vendor/json2.js"></script>
|
||||
<script src="../vendor/underscore/test/vendor/jquery.js"></script>
|
||||
<script src="../vendor/underscore/test/vendor/qunit.js"></script>
|
||||
<script src="../vendor/underscore/test/vendor/jslitmus.js"></script>
|
||||
|
||||
Reference in New Issue
Block a user