Don't remove nonEnumArgs fixes for mobile builds and cleanup debug builds.

Former-commit-id: b1fbb7ed362d0c94a92e4b12e0385c77973654b3
This commit is contained in:
John-David Dalton
2013-02-05 22:54:18 -08:00
parent f5ab24b8d2
commit 5787436177
3 changed files with 15 additions and 71 deletions

View File

@@ -86,7 +86,7 @@ lodash legacy
lodash modern
```
* Mobile builds, without method compilation and bug fixes for old browsers, may be created using the `mobile` modifier argument.
* Mobile builds, without method compilation and most bug fixes for old browsers, may be created using the `mobile` modifier argument.
```bash
lodash mobile
```

View File

@@ -565,7 +565,7 @@
' lodash csp Build supporting default Content Security Policy restrictions',
' lodash legacy Build tailored for older environments without ES5 support',
' lodash modern Build tailored for newer environments with ES5 support',
' lodash mobile Build without method compilation and bug fixes for old browsers',
' lodash mobile Build without method compilation and most bug fixes for old browsers',
' lodash strict Build with `_.assign`, `_.bindAll`, & `_.defaults` in strict mode',
' lodash underscore Build tailored for projects already using Underscore',
' lodash include=... Comma separated method/category names to include in the build',
@@ -1600,8 +1600,11 @@
source = removeHasEnumPrototype(source);
source = removeIteratesOwnLast(source);
source = removeNoCharByIndex(source);
source = removeNonEnumArgs(source);
source = removeNoNodeClass(source);
if (!isMobile) {
source = removeNonEnumArgs(source);
}
}
if (isModern) {
// remove `_.isPlainObject` fallback
@@ -2123,9 +2126,6 @@
source = removeIsArgumentsFallback(source);
}
}
/*----------------------------------------------------------------------*/
if (isModern) {
source = removeArgsAreObjects(source);
source = removeHasObjectSpliceBug(source);
@@ -2300,10 +2300,7 @@
/*------------------------------------------------------------------------*/
if (isTemplate) {
debugSource = source;
}
else {
if (!isTemplate) {
// modify/remove references to removed methods/variables
if (isRemoved(source, 'invert')) {
source = replaceVar(source, 'htmlUnescapes', "{'&amp;':'&','&lt;':'<','&gt;':'>','&quot;':'\"','&#x27;':\"'\"}");
@@ -2331,16 +2328,7 @@
.replace(/(?:\s*\/\/.*)*\s*lodash\.prototype.+\n/g, '')
.replace(/(?:\s*\/\/.*)*\s*mixin\(lodash\).+\n/, '');
}
if (!source.match(/var (?:hasDontEnumBug|hasEnumPrototype|iteratesOwnLast|nonEnumArgs)\b/g)) {
// remove `hasDontEnumBug`, `hasEnumPrototype`, `iteratesOwnLast`, and `nonEnumArgs` assignments
source = source.replace(/^ *\(function\(\) *{[\s\S]+?}\(1\)\);\n/m, '');
}
// assign debug source before further modifications that rely on the minifier
// to remove unused variables and other dead code
debugSource = cleanupSource(source);
// remove associated functions, variables, and code snippets that the minifier may miss
// remove functions, variables, and snippets that the minifier may miss
if (isRemoved(source, 'clone')) {
source = removeVar(source, 'cloneableClasses');
source = removeVar(source, 'ctorByClass');
@@ -2350,7 +2338,7 @@
}
if (isRemoved(source, 'isPlainObject')) {
source = removeVar(source, 'getPrototypeOf');
source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var iteratesOwnLast;|.+?iteratesOwnLast *=.+/g, '');
source = removeIteratesOwnLast(source);
}
if (isRemoved(source, 'keys')) {
source = removeFunction(source, 'shimKeys');
@@ -2369,7 +2357,6 @@
source = removeFunction(source, 'createIterator');
source = removeHasDontEnumBug(source);
source = removeHasEnumPrototype(source);
source = removeNonEnumArgs(source);
}
if (isRemoved(source, 'createIterator', 'bind', 'keys')) {
source = removeVar(source, 'isBindFast');
@@ -2379,9 +2366,15 @@
if (isRemoved(source, 'createIterator', 'keys')) {
source = removeVar(source, 'nativeKeys');
source = removeKeysOptimization(source);
source = removeNonEnumArgs(source);
}
if (!source.match(/var (?:hasDontEnumBug|hasEnumPrototype|iteratesOwnLast|nonEnumArgs)\b/g)) {
// remove IIFE used to assign `hasDontEnumBug`, `hasEnumPrototype`, `iteratesOwnLast`, and `nonEnumArgs`
source = source.replace(/^ *\(function\(\) *{[\s\S]+?}\(1\)\);\n/m, '');
}
}
debugSource = cleanupSource(source);
source = cleanupSource(source);
/*------------------------------------------------------------------------*/

View File

@@ -74,7 +74,6 @@
var ceil = Math.ceil,
concat = arrayRef.concat,
floor = Math.floor,
getPrototypeOf = reNative.test(getPrototypeOf = Object.getPrototypeOf) && getPrototypeOf,
hasOwnProperty = objectRef.hasOwnProperty,
push = arrayRef.push,
toString = objectRef.toString;
@@ -422,54 +421,6 @@
return func;
}
/**
* Creates compiled iteration functions.
*
* @private
* @param {Object} [options1, options2, ...] The compile options object(s).
* arrays - A string of code to determine if the iterable is an array or array-like.
* useHas - A boolean to specify using `hasOwnProperty` checks in the object loop.
* args - A string of comma separated arguments the iteration function will accept.
* top - A string of code to execute before the iteration branches.
* loop - A string of code to execute in the object loop.
* bottom - A string of code to execute after the iteration branches.
*
* @returns {Function} Returns the compiled function.
*/
function createIterator() {
var data = {
// support properties
// iterator options
'arrays': 'isArray(iterable)',
'bottom': '',
'loop': '',
'top': '',
'useHas': true
};
// merge options into a template data object
for (var object, index = 0; object = arguments[index]; index++) {
for (var key in object) {
data[key] = object[key];
}
}
var args = data.args;
data.firstArg = /^[^,]+/.exec(args)[0];
// create the function factory
var factory = Function(
'createCallback, hasOwnProperty, isArguments, isArray, isString, ' +
'objectTypes, nativeKeys',
'return function(' + args + ') {\n' + (data) + '\n}'
);
// return the compiled function
return factory(
createCallback, hasOwnProperty, isArguments, isArray, isString,
objectTypes, nativeKeys
);
}
/**
* A function compiled to iterate `arguments` objects, arrays, objects, and
* strings consistenly across environments, executing the `callback` for each