From d87c7942a31744ab26d2ed03684bd956beeb3edb Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Mon, 29 Sep 2014 03:43:10 +1000 Subject: [PATCH] add property name shorthand support --- lib/6to5/transformers/property-name-shorthand.js | 3 +++ test/fixtures/property-name-shorthand/mixed/actual.js | 1 + test/fixtures/property-name-shorthand/mixed/expected.js | 5 +++++ test/fixtures/property-name-shorthand/multiple/actual.js | 1 + test/fixtures/property-name-shorthand/multiple/expected.js | 4 ++++ test/fixtures/property-name-shorthand/single/actual.js | 1 + test/fixtures/property-name-shorthand/single/expected.js | 3 +++ 7 files changed, 18 insertions(+) create mode 100644 test/fixtures/property-name-shorthand/mixed/actual.js create mode 100644 test/fixtures/property-name-shorthand/mixed/expected.js create mode 100644 test/fixtures/property-name-shorthand/multiple/actual.js create mode 100644 test/fixtures/property-name-shorthand/multiple/expected.js create mode 100644 test/fixtures/property-name-shorthand/single/actual.js create mode 100644 test/fixtures/property-name-shorthand/single/expected.js diff --git a/lib/6to5/transformers/property-name-shorthand.js b/lib/6to5/transformers/property-name-shorthand.js index e69de29bb2..27c303f0aa 100644 --- a/lib/6to5/transformers/property-name-shorthand.js +++ b/lib/6to5/transformers/property-name-shorthand.js @@ -0,0 +1,3 @@ +exports.Property = function (node) { + if (node.shorthand) node.shorthand = false; +}; diff --git a/test/fixtures/property-name-shorthand/mixed/actual.js b/test/fixtures/property-name-shorthand/mixed/actual.js new file mode 100644 index 0000000000..c2c49e0253 --- /dev/null +++ b/test/fixtures/property-name-shorthand/mixed/actual.js @@ -0,0 +1 @@ +var coords = { x, y, foo: "bar" }; diff --git a/test/fixtures/property-name-shorthand/mixed/expected.js b/test/fixtures/property-name-shorthand/mixed/expected.js new file mode 100644 index 0000000000..88427e8bfd --- /dev/null +++ b/test/fixtures/property-name-shorthand/mixed/expected.js @@ -0,0 +1,5 @@ +var coords = { + x: x, + y: y, + foo: "bar" +}; diff --git a/test/fixtures/property-name-shorthand/multiple/actual.js b/test/fixtures/property-name-shorthand/multiple/actual.js new file mode 100644 index 0000000000..224e1f6c7b --- /dev/null +++ b/test/fixtures/property-name-shorthand/multiple/actual.js @@ -0,0 +1 @@ +var coords = { x, y }; diff --git a/test/fixtures/property-name-shorthand/multiple/expected.js b/test/fixtures/property-name-shorthand/multiple/expected.js new file mode 100644 index 0000000000..e07257b750 --- /dev/null +++ b/test/fixtures/property-name-shorthand/multiple/expected.js @@ -0,0 +1,4 @@ +var coords = { + x: x, + y: y +}; diff --git a/test/fixtures/property-name-shorthand/single/actual.js b/test/fixtures/property-name-shorthand/single/actual.js new file mode 100644 index 0000000000..8cd0750474 --- /dev/null +++ b/test/fixtures/property-name-shorthand/single/actual.js @@ -0,0 +1 @@ +var coords = { x }; diff --git a/test/fixtures/property-name-shorthand/single/expected.js b/test/fixtures/property-name-shorthand/single/expected.js new file mode 100644 index 0000000000..9b14ab0e30 --- /dev/null +++ b/test/fixtures/property-name-shorthand/single/expected.js @@ -0,0 +1,3 @@ +var coords = { + x: x +};