diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-11-21 02:30:46 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-21 10:30:46 +0800 |
commit | 645d5a348bced192907176876b9e46c942e7d0ae (patch) | |
tree | ff51af3a2a307ddc6186ccc857ebbc5250a5e3b5 /lib | |
parent | cf120c7cea2721626caa67767d720431becf7f62 (diff) | |
download | tracifyjs-645d5a348bced192907176876b9e46c942e7d0ae.tar.gz tracifyjs-645d5a348bced192907176876b9e46c942e7d0ae.zip |
workaround Safari quirks (#4314)
fixes #1753
Diffstat (limited to 'lib')
-rw-r--r-- | lib/minify.js | 3 | ||||
-rw-r--r-- | lib/scope.js | 16 |
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/minify.js b/lib/minify.js index 5f363989..678fbca9 100644 --- a/lib/minify.js +++ b/lib/minify.js @@ -89,6 +89,7 @@ function minify(files, options) { toplevel: false, validate: false, warnings: false, + webkit: false, wrap: false, }, true); if (options.validate) AST_Node.enable_validation(); @@ -101,6 +102,7 @@ function minify(files, options) { set_shorthand("ie8", options, [ "compress", "mangle", "output" ]); set_shorthand("keep_fnames", options, [ "compress", "mangle" ]); set_shorthand("toplevel", options, [ "compress", "mangle" ]); + set_shorthand("webkit", options, [ "mangle", "output" ]); var quoted_props; if (options.mangle) { options.mangle = defaults(options.mangle, { @@ -111,6 +113,7 @@ function minify(files, options) { properties: false, reserved: [], toplevel: false, + webkit: false, }, true); if (options.mangle.properties) { if (typeof options.mangle.properties != "object") { diff --git a/lib/scope.js b/lib/scope.js index 4cc65c75..4d080fee 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -486,6 +486,7 @@ function _default_mangler_options(options) { keep_fnames : false, reserved : [], toplevel : false, + webkit : false, }); if (!Array.isArray(options.reserved)) options.reserved = []; // Never mangle arguments @@ -520,6 +521,21 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options) { return true; } if (node instanceof AST_BlockScope) { + if (options.webkit && node instanceof AST_IterationStatement && node.init instanceof AST_Let) { + node.init.definitions.forEach(function(defn) { + defn.name.match_symbol(function(sym) { + if (!(sym instanceof AST_SymbolLet)) return; + var def = sym.definition(); + var scope = sym.scope.parent_scope; + var redef = scope.def_variable(sym); + sym.thedef = def; + scope.to_mangle.push(redef); + def.redefined = function() { + return redef; + }; + }); + }, true); + } node.to_mangle = []; node.variables.each(function(def) { if (!defer_redef(def)) node.to_mangle.push(def); |