|
1735 | 1735 | dependencyMap.defer = _.without(dependencyMap.defer, 'bind');
|
1736 | 1736 | }
|
1737 | 1737 | if (isModern) {
|
1738 |
| - dependencyMap.isEmpty = _.without(dependencyMap.isEmpty, 'isArguments'); |
1739 |
| - dependencyMap.isEqual = _.without(dependencyMap.isEqual, 'isArguments'); |
1740 |
| - dependencyMap.isPlainObject = _.without(dependencyMap.isPlainObject, 'isArguments'); |
1741 |
| - dependencyMap.keys = _.without(dependencyMap.keys, 'isArguments'); |
1742 | 1738 | dependencyMap.reduceRight = _.without(dependencyMap.reduceRight, 'isString');
|
| 1739 | + |
| 1740 | + if (!isMobile) { |
| 1741 | + dependencyMap.isEmpty = _.without(dependencyMap.isEmpty, 'isArguments'); |
| 1742 | + dependencyMap.isEqual = _.without(dependencyMap.isEqual, 'isArguments'); |
| 1743 | + dependencyMap.isPlainObject = _.without(dependencyMap.isPlainObject, 'isArguments'); |
| 1744 | + dependencyMap.keys = _.without(dependencyMap.keys, 'isArguments'); |
| 1745 | + } |
1743 | 1746 | }
|
1744 | 1747 | if (isUnderscore) {
|
1745 | 1748 | dependencyMap.contains = _.without(dependencyMap.contains, 'isString');
|
|
1763 | 1766 | }
|
1764 | 1767 | if (isModern || isUnderscore) {
|
1765 | 1768 | dependencyMap.at = _.without(dependencyMap.at, 'isString');
|
1766 |
| - dependencyMap.forEach = _.without(dependencyMap.forEach, 'isArguments', 'isString'); |
1767 |
| - dependencyMap.forIn = _.without(dependencyMap.forIn, 'isArguments'); |
1768 |
| - dependencyMap.forOwn = _.without(dependencyMap.forOwn, 'isArguments'); |
| 1769 | + dependencyMap.forEach = _.without(dependencyMap.forEach, 'isString'); |
1769 | 1770 | dependencyMap.toArray = _.without(dependencyMap.toArray, 'isString');
|
1770 | 1771 |
|
1771 | 1772 | if (!isMobile) {
|
1772 | 1773 | dependencyMap.every = _.without(dependencyMap.every, 'isArray');
|
1773 | 1774 | dependencyMap.find = _.without(dependencyMap.find, 'isArray');
|
1774 | 1775 | dependencyMap.filter = _.without(dependencyMap.filter, 'isArray');
|
1775 |
| - dependencyMap.forEach = _.without(dependencyMap.forEach, 'isArray'); |
| 1776 | + dependencyMap.forEach = _.without(dependencyMap.forEach, 'isArguments', 'isArray'); |
| 1777 | + dependencyMap.forIn = _.without(dependencyMap.forIn, 'isArguments'); |
| 1778 | + dependencyMap.forOwn = _.without(dependencyMap.forOwn, 'isArguments'); |
1776 | 1779 | dependencyMap.map = _.without(dependencyMap.map, 'isArray');
|
1777 | 1780 | dependencyMap.max.push('forEach');
|
1778 | 1781 | dependencyMap.min.push('forEach');
|
|
1891 | 1894 | source = removeSupportSpliceObjects(source);
|
1892 | 1895 | source = removeIsArgumentsFallback(source);
|
1893 | 1896 |
|
1894 |
| - // remove `_.isPlainObject` fallback |
1895 |
| - source = source.replace(matchFunction(source, 'isPlainObject'), function(match) { |
1896 |
| - return match.replace(/!getPrototypeOf[^:]+:\s*/, ''); |
1897 |
| - }); |
1898 |
| - |
1899 |
| - if (!isMobile) { |
| 1897 | + if (isMobile) { |
| 1898 | + source = replaceSupportProp(source, 'enumPrototypes', 'true'); |
| 1899 | + source = replaceSupportProp(source, 'nonEnumArgs', 'true'); |
| 1900 | + } |
| 1901 | + else { |
1900 | 1902 | source = removeIsFunctionFallback(source);
|
| 1903 | + |
| 1904 | + // remove `shimIsPlainObject` from `_.isPlainObject` |
| 1905 | + source = source.replace(matchFunction(source, 'isPlainObject'), function(match) { |
| 1906 | + return match.replace(/!getPrototypeOf[^:]+:\s*/, ''); |
| 1907 | + }); |
1901 | 1908 | }
|
1902 | 1909 | }
|
1903 | 1910 | if (isMobile || isUnderscore) {
|
|
1907 | 1914 | if (isModern || isUnderscore) {
|
1908 | 1915 | source = removeSupportArgsClass(source);
|
1909 | 1916 | source = removeSupportNonEnumShadows(source);
|
1910 |
| - source = removeSupportEnumPrototypes(source); |
1911 | 1917 | source = removeSupportOwnLast(source);
|
1912 | 1918 | source = removeSupportUnindexedChars(source);
|
1913 | 1919 | source = removeSupportNodeClass(source);
|
1914 | 1920 |
|
1915 | 1921 | if (!isMobile) {
|
| 1922 | + source = removeSupportEnumPrototypes(source); |
1916 | 1923 | source = removeSupportNonEnumArgs(source);
|
1917 | 1924 |
|
1918 | 1925 | // replace `_.forEach`
|
|
2866 | 2873 | source = removeVar(source, 'iteratorTemplate');
|
2867 | 2874 | source = removeVar(source, 'templateIterator');
|
2868 | 2875 | source = removeSupportNonEnumShadows(source);
|
2869 |
| - source = removeSupportEnumPrototypes(source); |
2870 |
| - } |
2871 |
| - if (!/support\.(?:enumPrototypes|nonEnumShadows|ownLast)\b/.test(source)) { |
2872 |
| - // remove code used to resolve unneeded `support` properties |
2873 |
| - source = source.replace(/^ *\(function[\s\S]+?\n(( *)var ctor *= *function[\s\S]+?(?:\n *for.+)+\n)([\s\S]+?)}\(1\)\);\n/m, function(match, setup, indent, body) { |
2874 |
| - if (/support\.spliceObjects\b/.test(match)) { |
2875 |
| - return match.replace(setup, indent + "var object = { '0': 1, 'length': 1 };\n"); |
2876 |
| - } else if (/support\.nonEnumArgs\b/.test(match)) { |
2877 |
| - return match.replace(setup, indent + 'for (var prop in arguments) { }\n'); |
2878 |
| - } |
2879 |
| - return body.replace(RegExp('^' + indent, 'gm'), indent.slice(0, -2)); |
2880 |
| - }); |
2881 | 2876 | }
|
| 2877 | + // remove code used to resolve unneeded `support` properties |
| 2878 | + source = source.replace(/^ *\(function[\s\S]+?\n(( *)var ctor *= *function[\s\S]+?(?:\n *for.+)+\n)([\s\S]+?)}\(1\)\);\n/m, function(match, setup, indent, body) { |
| 2879 | + var modified = setup; |
| 2880 | + if (!/support\.spliceObjects *=(?! *(?:false|true))/.test(match)) { |
| 2881 | + modified = modified.replace(/^ *object *=.+\n/m, ''); |
| 2882 | + } |
| 2883 | + if (!/support\.enumPrototypes *=(?! *(?:false|true))/.test(match) && |
| 2884 | + !/support\.nonEnumShadows *=(?! *(?:false|true))/.test(match) && |
| 2885 | + !/support\.ownLast *=(?! *(?:false|true))/.test(match)) { |
| 2886 | + modified = modified |
| 2887 | + .replace(/\bctor *=.+\s+/, '') |
| 2888 | + .replace(/^ *ctor\.prototype.+\s+.+\n/m, '') |
| 2889 | + .replace(/(?:,\n)? *props *=[^;]+/, '') |
| 2890 | + .replace(/^ *for *\((?=prop)/, '$&var ') |
| 2891 | + } |
| 2892 | + if (!/support\.nonEnumArgs *=(?! *(?:false|true))/.test(match)) { |
| 2893 | + modified = modified.replace(/^ *for *\(.+? arguments.+\n/m, ''
8560
;); |
| 2894 | + } |
| 2895 | + // cleanup the empty var statement |
| 2896 | + modified = modified.replace(/^ *var;\n/m, ''); |
| 2897 | + |
| 2898 | + // if no setup then remove IIFE |
| 2899 | + return /^\s*$/.test(modified) |
| 2900 | + ? body.replace(RegExp('^' + indent, 'gm'), indent.slice(0, -2)) |
| 2901 | + : match.replace(setup, modified); |
| 2902 | + }); |
2882 | 2903 | }
|
2883 | 2904 | if (_.size(source.match(/\bfreeModule\b/g)) < 2) {
|
2884 | 2905 | source = removeVar(source, 'freeModule');
|
|
0 commit comments