diff --git a/packages/ember-glimmer/lib/helpers/action.js b/packages/ember-glimmer/lib/helpers/action.js index 4a8a6afdbb2..1fb35d107a5 100644 --- a/packages/ember-glimmer/lib/helpers/action.js +++ b/packages/ember-glimmer/lib/helpers/action.js @@ -13,6 +13,7 @@ import { } from 'ember-metal'; export const INVOKE = symbol('INVOKE'); +export const ACTION = symbol('ACTION'); /** The `{{action}}` helper provides a way to pass triggers for behavior (usually @@ -341,6 +342,7 @@ export function createClosureAction(target, action, valuePath, actionArgs) { if (actionArgLength > 0) { closureAction = function(...passedArguments) { + let args = new Array(actionArgLength + passedArguments.length); for (let i = 0; i < actionArgLength; i++) { @@ -373,5 +375,6 @@ export function createClosureAction(target, action, valuePath, actionArgs) { }; } + closureAction[ACTION] = true; return closureAction; } diff --git a/packages/ember-glimmer/lib/utils/process-args.js b/packages/ember-glimmer/lib/utils/process-args.js index 85cc3730c95..820fb09f692 100644 --- a/packages/ember-glimmer/lib/utils/process-args.js +++ b/packages/ember-glimmer/lib/utils/process-args.js @@ -3,6 +3,7 @@ import { CONSTANT_TAG } from 'glimmer-reference'; import { ARGS } from '../component'; import { UPDATE } from './references'; import { MUTABLE_CELL } from 'ember-views'; +import { ACTION } from '../helpers/action'; export default function processArgs(args, positionalParamsDefinition) { if (!positionalParamsDefinition || positionalParamsDefinition.length === 0 || args.positional.length === 0) { @@ -50,7 +51,9 @@ class SimpleArgs { let ref = namedArgs.get(name); let value = attrs[name]; - if (ref[UPDATE]) { + if (typeof value === 'function' && value[ACTION]) { + attrs[name] = value; + } else if (ref[UPDATE]) { attrs[name] = new MutableCell(ref, value); } diff --git a/packages/ember-glimmer/tests/integration/helpers/closure-action-test.js b/packages/ember-glimmer/tests/integration/helpers/closure-action-test.js index da754626693..12495ae5507 100644 --- a/packages/ember-glimmer/tests/integration/helpers/closure-action-test.js +++ b/packages/ember-glimmer/tests/integration/helpers/closure-action-test.js @@ -970,7 +970,7 @@ moduleFor('Helpers test: closure {{action}}', class extends RenderingTest { this.render('{{outer-component}}'); this.runTask(() => { - innerComponent.fireAction(); + actualReturnedValue = innerComponent.fireAction(); }); this.assert.equal(actualFirst, first, 'first argument is correct');