Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX beta] Provide a helpful error for undefined closure actions. #12241

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ export default function closureAction(morph, env, scope, params, hash, template,
// look to "target".
target = read(scope.self);
action = read(rawAction);
if (typeof action === 'string') {
let actionType = typeof action;

if (actionType === 'string') {
let actionName = action;
action = null;
// on-change={{action 'setName'}}
Expand All @@ -42,6 +44,8 @@ export default function closureAction(morph, env, scope, params, hash, template,
if (!action) {
throw new EmberError(`An action named '${actionName}' was not found in ${target}.`);
}
} else if (actionType !== 'function') {
throw new EmberError(`An action could not be made for \`${rawAction.label}\` in ${target}. Please confirm that you are using either a quoted action name (i.e. \`(action '${rawAction.label}')\`) or a function available in ${target}.`);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@ QUnit.test('action should be called', function(assert) {
});
});

QUnit.test('an error is triggered when bound action function is undefined', function(assert) {
assert.expect(1);

innerComponent = EmberComponent.extend({
}).create();

outerComponent = EmberComponent.extend({
layout: compile('{{view innerComponent submit=(action somethingThatIsUndefined)}}'),
innerComponent
}).create();

throws(function() {
runAppend(outerComponent);
}, /An action could not be made for `somethingThatIsUndefined` in .*\. Please confirm that you are using either a quoted action name \(i\.e\. `\(action 'somethingThatIsUndefined'\)`\) or a function available in .*\./);
});

QUnit.test('action value is returned', function(assert) {
assert.expect(1);

Expand Down