mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-13 04:17:49 +00:00
Don't remove nonEnumArgs fixes for mobile builds and cleanup debug builds.
Former-commit-id: b1fbb7ed362d0c94a92e4b12e0385c77973654b3
This commit is contained in:
@@ -86,7 +86,7 @@ lodash legacy
|
|||||||
lodash modern
|
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
|
```bash
|
||||||
lodash mobile
|
lodash mobile
|
||||||
```
|
```
|
||||||
|
|||||||
35
build.js
35
build.js
@@ -565,7 +565,7 @@
|
|||||||
' lodash csp Build supporting default Content Security Policy restrictions',
|
' lodash csp Build supporting default Content Security Policy restrictions',
|
||||||
' lodash legacy Build tailored for older environments without ES5 support',
|
' lodash legacy Build tailored for older environments without ES5 support',
|
||||||
' lodash modern Build tailored for newer environments with 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 strict Build with `_.assign`, `_.bindAll`, & `_.defaults` in strict mode',
|
||||||
' lodash underscore Build tailored for projects already using Underscore',
|
' lodash underscore Build tailored for projects already using Underscore',
|
||||||
' lodash include=... Comma separated method/category names to include in the build',
|
' lodash include=... Comma separated method/category names to include in the build',
|
||||||
@@ -1600,8 +1600,11 @@
|
|||||||
source = removeHasEnumPrototype(source);
|
source = removeHasEnumPrototype(source);
|
||||||
source = removeIteratesOwnLast(source);
|
source = removeIteratesOwnLast(source);
|
||||||
source = removeNoCharByIndex(source);
|
source = removeNoCharByIndex(source);
|
||||||
source = removeNonEnumArgs(source);
|
|
||||||
source = removeNoNodeClass(source);
|
source = removeNoNodeClass(source);
|
||||||
|
|
||||||
|
if (!isMobile) {
|
||||||
|
source = removeNonEnumArgs(source);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (isModern) {
|
if (isModern) {
|
||||||
// remove `_.isPlainObject` fallback
|
// remove `_.isPlainObject` fallback
|
||||||
@@ -2123,9 +2126,6 @@
|
|||||||
source = removeIsArgumentsFallback(source);
|
source = removeIsArgumentsFallback(source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
if (isModern) {
|
if (isModern) {
|
||||||
source = removeArgsAreObjects(source);
|
source = removeArgsAreObjects(source);
|
||||||
source = removeHasObjectSpliceBug(source);
|
source = removeHasObjectSpliceBug(source);
|
||||||
@@ -2300,10 +2300,7 @@
|
|||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
if (isTemplate) {
|
if (!isTemplate) {
|
||||||
debugSource = source;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// modify/remove references to removed methods/variables
|
// modify/remove references to removed methods/variables
|
||||||
if (isRemoved(source, 'invert')) {
|
if (isRemoved(source, 'invert')) {
|
||||||
source = replaceVar(source, 'htmlUnescapes', "{'&':'&','<':'<','>':'>','"':'\"',''':\"'\"}");
|
source = replaceVar(source, 'htmlUnescapes', "{'&':'&','<':'<','>':'>','"':'\"',''':\"'\"}");
|
||||||
@@ -2331,16 +2328,7 @@
|
|||||||
.replace(/(?:\s*\/\/.*)*\s*lodash\.prototype.+\n/g, '')
|
.replace(/(?:\s*\/\/.*)*\s*lodash\.prototype.+\n/g, '')
|
||||||
.replace(/(?:\s*\/\/.*)*\s*mixin\(lodash\).+\n/, '');
|
.replace(/(?:\s*\/\/.*)*\s*mixin\(lodash\).+\n/, '');
|
||||||
}
|
}
|
||||||
if (!source.match(/var (?:hasDontEnumBug|hasEnumPrototype|iteratesOwnLast|nonEnumArgs)\b/g)) {
|
// remove functions, variables, and snippets that the minifier may miss
|
||||||
// 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
|
|
||||||
if (isRemoved(source, 'clone')) {
|
if (isRemoved(source, 'clone')) {
|
||||||
source = removeVar(source, 'cloneableClasses');
|
source = removeVar(source, 'cloneableClasses');
|
||||||
source = removeVar(source, 'ctorByClass');
|
source = removeVar(source, 'ctorByClass');
|
||||||
@@ -2350,7 +2338,7 @@
|
|||||||
}
|
}
|
||||||
if (isRemoved(source, 'isPlainObject')) {
|
if (isRemoved(source, 'isPlainObject')) {
|
||||||
source = removeVar(source, 'getPrototypeOf');
|
source = removeVar(source, 'getPrototypeOf');
|
||||||
source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var iteratesOwnLast;|.+?iteratesOwnLast *=.+/g, '');
|
source = removeIteratesOwnLast(source);
|
||||||
}
|
}
|
||||||
if (isRemoved(source, 'keys')) {
|
if (isRemoved(source, 'keys')) {
|
||||||
source = removeFunction(source, 'shimKeys');
|
source = removeFunction(source, 'shimKeys');
|
||||||
@@ -2369,7 +2357,6 @@
|
|||||||
source = removeFunction(source, 'createIterator');
|
source = removeFunction(source, 'createIterator');
|
||||||
source = removeHasDontEnumBug(source);
|
source = removeHasDontEnumBug(source);
|
||||||
source = removeHasEnumPrototype(source);
|
source = removeHasEnumPrototype(source);
|
||||||
source = removeNonEnumArgs(source);
|
|
||||||
}
|
}
|
||||||
if (isRemoved(source, 'createIterator', 'bind', 'keys')) {
|
if (isRemoved(source, 'createIterator', 'bind', 'keys')) {
|
||||||
source = removeVar(source, 'isBindFast');
|
source = removeVar(source, 'isBindFast');
|
||||||
@@ -2379,9 +2366,15 @@
|
|||||||
if (isRemoved(source, 'createIterator', 'keys')) {
|
if (isRemoved(source, 'createIterator', 'keys')) {
|
||||||
source = removeVar(source, 'nativeKeys');
|
source = removeVar(source, 'nativeKeys');
|
||||||
source = removeKeysOptimization(source);
|
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);
|
source = cleanupSource(source);
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|||||||
49
dist/lodash.underscore.js
vendored
49
dist/lodash.underscore.js
vendored
@@ -74,7 +74,6 @@
|
|||||||
var ceil = Math.ceil,
|
var ceil = Math.ceil,
|
||||||
concat = arrayRef.concat,
|
concat = arrayRef.concat,
|
||||||
floor = Math.floor,
|
floor = Math.floor,
|
||||||
getPrototypeOf = reNative.test(getPrototypeOf = Object.getPrototypeOf) && getPrototypeOf,
|
|
||||||
hasOwnProperty = objectRef.hasOwnProperty,
|
hasOwnProperty = objectRef.hasOwnProperty,
|
||||||
push = arrayRef.push,
|
push = arrayRef.push,
|
||||||
toString = objectRef.toString;
|
toString = objectRef.toString;
|
||||||
@@ -422,54 +421,6 @@
|
|||||||
return func;
|
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
|
* A function compiled to iterate `arguments` objects, arrays, objects, and
|
||||||
* strings consistenly across environments, executing the `callback` for each
|
* strings consistenly across environments, executing the `callback` for each
|
||||||
|
|||||||
Reference in New Issue
Block a user