From 1934c16f0f477ff5a5f75688e49477fe6c983690 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Mon, 1 Jun 2015 22:32:04 +0100 Subject: [PATCH] don't use initializer property for decorators on concise methods in object literals --- src/babel/transformation/transformers/es7/decorators.js | 2 +- .../fixtures/transformation/es7.decorators/object/expected.js | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/babel/transformation/transformers/es7/decorators.js b/src/babel/transformation/transformers/es7/decorators.js index 6f927f3ee0..d875317c56 100644 --- a/src/babel/transformation/transformers/es7/decorators.js +++ b/src/babel/transformation/transformers/es7/decorators.js @@ -26,7 +26,7 @@ export function ObjectExpression(node, parent, scope, file) { if (prop.decorators) memoiseDecorators(prop.decorators, scope); - if (prop.kind === "init") { + if (prop.kind === "init" && !prop.method) { prop.kind = ""; prop.value = t.functionExpression(null, [], t.blockStatement([ t.returnStatement(prop.value) diff --git a/test/core/fixtures/transformation/es7.decorators/object/expected.js b/test/core/fixtures/transformation/es7.decorators/object/expected.js index 7a7cc30560..ae77a208df 100644 --- a/test/core/fixtures/transformation/es7.decorators/object/expected.js +++ b/test/core/fixtures/transformation/es7.decorators/object/expected.js @@ -3,9 +3,7 @@ var obj = babelHelpers.createDecoratedObject([{ key: "bar", decorators: [foo], - initializer: function () { - return function bar() {}; - } + value: function bar() {} }, { key: "foo", decorators: [bar],