Skip to content

Commit 652e71c

Browse files
ssutarChris Garrett
authored andcommitted
[Bugfix] Fix an issue with wrapComputed (#108)
1 parent f61fdd2 commit 652e71c

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

transforms/ember-object/__testfixtures__/runtime.data.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"data": [
33
{
44
"./transforms/ember-object/__testfixtures__/runtime.input.js": {
5-
"computedProperties": ["computedMacro"],
5+
"computedProperties": ["computedMacro", "numPlusOne", "numPlusPlus"],
66
"observedProperties": [],
77
"observerProperties": {},
88
"offProperties": { "offProp": ["prop1", "prop2"] },

transforms/ember-object/__testfixtures__/runtime.input.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import RuntimeInput from "common/runtime/input";
2+
import { alias } from "@ember/object/computed";
3+
import { computed } from "@ember/object";
24

35
/**
46
* Program comments
@@ -16,6 +18,12 @@ export default RuntimeInput.extend(MyMixin, {
1618
unobservedProp: null,
1719
offProp: null,
1820

21+
numPlusOne: computed("numProp", function() {
22+
return this.get("numProp") + 1;
23+
}),
24+
25+
numPlusPlus: alias("numPlusOne"),
26+
1927
computedMacro: customMacro(),
2028

2129
/**

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { action, off, unobserves, wrapComputed } from "@ember-decorators/object";
1+
import { action, off, unobserves, wrapComputed, computed } from "@ember-decorators/object";
2+
import { alias } from "@ember-decorators/object/computed";
23
import RuntimeInput from "common/runtime/input";
34

45
/**
@@ -21,6 +22,14 @@ export default class RuntimeInputEmberObject extends RuntimeInput.extend(MyMixin
2122
@off("prop1", "prop2")
2223
offProp;
2324

25+
@computed("numProp")
26+
get numPlusOne() {
27+
return this.get("numProp") + 1;
28+
}
29+
30+
@alias("numPlusOne")
31+
numPlusPlus;
32+
2433
@wrapComputed(customMacro())
2534
computedMacro;
2635

transforms/helpers/EOProp.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,14 @@ class EOProp {
172172
this.setCallExpressionProps();
173173
const {
174174
decoratorName,
175-
isComputedDecorator,
176175
isMethodDecorator,
177176
isMetaDecorator,
178177
importedName
179178
} = importedDecoratedProps[this.calleeName] || {};
180179
if (decoratorName) {
181180
this.hasMapDecorator = importedName === "map";
182181
this.hasFilterDecorator = importedName === "filter";
183-
this.hasComputedDecorator = isComputedDecorator;
182+
this.hasComputedDecorator = importedName === "computed";
184183
this.hasMethodDecorator = isMethodDecorator;
185184
this.hasMetaDecorator = isMetaDecorator;
186185
this.decoratorNames.push(decoratorName);
@@ -221,7 +220,11 @@ class EOProp {
221220
this.decoratorNames.push("off");
222221
this.decoratorArgs["off"] = offProperties[name];
223222
}
224-
if (computedProperties.includes(name) && !this.hasComputedDecorator) {
223+
if (
224+
computedProperties.includes(name) &&
225+
!this.hasComputedDecorator &&
226+
!this.hasMetaDecorator
227+
) {
225228
this.decoratorNames.push("wrapComputed");
226229
}
227230
if (this.isAction) {

0 commit comments

Comments
 (0)