Skip to content

Commit 05fd916

Browse files
committed
Make attr.actionFn work
1 parent cdd1087 commit 05fd916

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

packages/ember-glimmer/lib/helpers/action.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
} from 'ember-metal';
1414

1515
export const INVOKE = symbol('INVOKE');
16+
export const ACTION = symbol('ACTION');
1617

1718
/**
1819
The `{{action}}` helper provides a way to pass triggers for behavior (usually
@@ -373,5 +374,6 @@ export function createClosureAction(target, action, valuePath, actionArgs) {
373374
};
374375
}
375376

377+
closureAction[ACTION] = true;
376378
return closureAction;
377379
}

packages/ember-glimmer/lib/utils/process-args.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { CONSTANT_TAG } from 'glimmer-reference';
33
import { ARGS } from '../component';
44
import { UPDATE } from './references';
55
import { MUTABLE_CELL } from 'ember-views';
6+
import { ACTION } from '../helpers/action';
67

78
export default function processArgs(args, positionalParamsDefinition) {
89
if (!positionalParamsDefinition || positionalParamsDefinition.length === 0 || args.positional.length === 0) {
@@ -50,7 +51,9 @@ class SimpleArgs {
5051
let ref = namedArgs.get(name);
5152
let value = attrs[name];
5253

53-
if (ref[UPDATE]) {
54+
if (typeof value === 'function' && value[ACTION]) {
55+
attrs[name] = value;
56+
} else if (ref[UPDATE]) {
5457
attrs[name] = new MutableCell(ref, value);
5558
}
5659

packages/ember-glimmer/tests/integration/helpers/closure-action-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ moduleFor('Helpers test: closure {{action}}', class extends RenderingTest {
970970
this.render('{{outer-component}}');
971971

972972
this.runTask(() => {
973-
innerComponent.fireAction();
973+
actualReturnedValue = innerComponent.fireAction();
974974
});
975975

976976
this.assert.equal(actualFirst, first, 'first argument is correct');

0 commit comments

Comments
 (0)