diff options
author | Shrey Banga <shrey@quip.com> | 2016-05-05 13:44:59 -0700 |
---|---|---|
committer | Richard van Velzen <rvanvelzen1@gmail.com> | 2016-06-19 21:13:31 +0200 |
commit | e645ba84cfc950183a222c2cce2ea6b94fe51226 (patch) | |
tree | 9ca5d7b1d55c36adb14f0468d4442f2a3a0aeb2d /test/compress/properties.js | |
parent | 6c99816855b650c6804a67f4891c339a3e8970f4 (diff) | |
download | tracifyjs-e645ba84cfc950183a222c2cce2ea6b94fe51226.tar.gz tracifyjs-e645ba84cfc950183a222c2cce2ea6b94fe51226.zip |
Respect quote style in object literals
The option added in fbbaa42ee55a7f753f7cab9b1a905ccf73cf26d5 wasn't
being respected inside object literals, so quoted property names would
still be stripped out with this option.
This is mostly a corner-case, but useful when the output is passed to
something like the Closure compiler, where quoted property names can be
used to prevent mangling.
Diffstat (limited to 'test/compress/properties.js')
-rw-r--r-- | test/compress/properties.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/test/compress/properties.js b/test/compress/properties.js index 39470738..574c5142 100644 --- a/test/compress/properties.js +++ b/test/compress/properties.js @@ -72,3 +72,54 @@ evaluate_length: { a = ("foo" + b).length; } } + +mangle_properties: { + mangle_props = { + ignore_quoted: false + }; + input: { + a["foo"] = "bar"; + a.color = "red"; + x = {"bar": 10}; + } + expect: { + a["a"] = "bar"; + a.b = "red"; + x = {c: 10}; + } +} + +mangle_unquoted_properties: { + mangle_props = { + ignore_quoted: true + } + beautify = { + beautify: false, + quote_style: 3, + keep_quoted_props: true, + } + input: { + function f1() { + a["foo"] = "bar"; + a.color = "red"; + x = {"bar": 10}; + } + function f2() { + a.foo = "bar"; + a['color'] = "red"; + x = {bar: 10}; + } + } + expect: { + function f1() { + a["foo"] = "bar"; + a.a = "red"; + x = {"bar": 10}; + } + function f2() { + a.b = "bar"; + a['color'] = "red"; + x = {c: 10}; + } + } +} |