Skip to content

Commit f0bda10

Browse files
ssutarpzuraq
authored andcommitted
Fix the classNames decorator declaration (#33)
#29
1 parent d556832 commit f0bda10

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

transforms/ember-object/__testfixtures__/decorators.output.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { on } from "@ember-decorators/object/evented";
88
import templateLayout from "components/templates/foo";
99

1010
@tagName("div")
11-
@classNames(["test-class", "custom-class"])
11+
@classNames("test-class", "custom-class")
1212
class Foo extends EmberObject {
1313
a = "";
1414

transforms/helpers/decorator-helper.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,14 @@ function withDecorators(to, decorators = []) {
2121
* @returns {Decorator[]}
2222
*/
2323
function createClassDecorator(j, classDecoratorProp) {
24+
let decoratorArgs = [];
25+
if (classDecoratorProp.type === "ArrayExpression") {
26+
decoratorArgs = classDecoratorProp.value.elements;
27+
} else {
28+
decoratorArgs = [classDecoratorProp.value];
29+
}
2430
return j.decorator(
25-
j.callExpression(j.identifier(classDecoratorProp.key.name), [
26-
classDecoratorProp.value
27-
])
31+
j.callExpression(j.identifier(classDecoratorProp.name), [...decoratorArgs])
2832
);
2933
}
3034

0 commit comments

Comments
 (0)