|
50 | 50 |
|
51 | 51 | if (isStrict) {
|
52 | 52 | source = setUseStrictOption(source, true);
|
53 |
| - } |
54 |
| - else if (!useStrict) { |
| 53 | + } else { |
55 | 54 | source = removeUseStrictDirective(source);
|
56 |
| - source = setUseStrictOption(source, false); |
| 55 | + if (!useStrict) { |
| 56 | + source = setUseStrictOption(source, false); |
| 57 | + } |
57 | 58 | }
|
58 | 59 |
|
59 | 60 | if (isLegacy) {
|
60 | 61 | source = replaceVar(source, 'noArgsClass', 'true');
|
61 |
| - ['isBindFast', 'isKeysFast', 'nativeBind', 'nativeIsArray', 'nativeKeys'].forEach(function(varName) { |
| 62 | + ['isBindFast', 'isKeysFast', 'isStrictFast', 'nativeBind', 'nativeIsArray', 'nativeKeys'].forEach(function(varName) { |
62 | 63 | source = replaceVar(source, varName, 'false');
|
63 | 64 | });
|
64 | 65 | }
|
|
686 | 687 | * @returns {String} Returns the modified source.
|
687 | 688 | */
|
688 | 689 | function setUseStrictOption(source, value) {
|
689 |
| - return source |
| 690 | + // remove `isStrictFast` assignment |
| 691 | + return removeVar(source, 'isStrictFast') |
690 | 692 | // replace `useStrict` branch in `value` with hard-coded option
|
691 | 693 | .replace(/(?: *\/\/.*\n)*(\s*)' *<% *if *\(useStrict\).+/, value ? "$1'\\'use strict\\';\\n' +" : '')
|
692 | 694 | // remove `useStrict` from iterator options
|
693 | 695 | .replace(/ *'useStrict': *false,\n/g, '')
|
| 696 | + // remove `useStrict` variable assignment in `createIterator` |
| 697 | + .replace(/,\s*useStrict *=[^;]+/, '') |
694 | 698 | // remove `useStrict` data object property assignment in `createIterator`
|
695 | 699 | .replace(/\s*.+?\.useStrict *=.+/, '');
|
696 | 700 | }
|
|
708 | 712 | source = source.replace(/prototype\s*=\s*{\s*valueOf\s*:\s*1\s*}/, 'prototype={valueOf:1,y:1}');
|
709 | 713 |
|
710 | 714 | // re-remove "use strict" added by the minifier
|
711 |
| - if (!useStrict) { |
| 715 | + if (!isStrict) { |
712 | 716 | source = removeUseStrictDirective(source);
|
713 | 717 | }
|
714 | 718 | fs.writeFileSync(path.join(cwd, filename), source);
|
|
1057 | 1061 | debugSource = source;
|
1058 | 1062 |
|
1059 | 1063 | // remove associated functions, variables, and code snippets that the minifier may miss
|
1060 |
| - if (isRemoved(source, 'bind')) { |
1061 |
| - source = removeVar(source, 'nativeBind'); |
1062 |
| - source = removeVar(source, 'isBindFast'); |
1063 |
| - } |
1064 | 1064 | if (isRemoved(source, 'isArray')) {
|
1065 | 1065 | source = removeVar(source, 'nativeIsArray');
|
1066 | 1066 | }
|
|
1087 | 1087 | source = removeFunction(source, 'createIterator');
|
1088 | 1088 | source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var noArgsEnum;|.+?noArgsEnum *=.+/g, '');
|
1089 | 1089 | }
|
| 1090 | + if (isRemoved(source, 'createIterator', 'bind')) { |
| 1091 | + source = removeVar(source, 'isBindFast'); |
| 1092 | + source = removeVar(source, 'isStrictFast'); |
| 1093 | + source = removeVar(source, 'nativeBind'); |
| 1094 | + } |
1090 | 1095 | if (isRemoved(source, 'createIterator', 'bind', 'isArray', 'keys')) {
|
1091 | 1096 | source = removeVar(source, 'reNative');
|
1092 | 1097 | }
|
|
0 commit comments