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

Revert "improve fn & on undefined callback message" #18870

Merged
merged 1 commit into from
Apr 13, 2020
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
3 changes: 1 addition & 2 deletions packages/@ember/-internals/glimmer/lib/helpers/fn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,8 @@ function fn({ positional }: CapturedArguments) {
if (DEBUG && typeof callbackRef[INVOKE] !== 'function') {
let callback = callbackRef.value();

const debug = (<any>callbackRef).debug && (<any>callbackRef).debug();
assert(
`You must pass a function as the \`fn\` helpers first argument, you passed ${debug} to \`fn\` but it was ${callback}`,
`You must pass a function as the \`fn\` helpers first argument, you passed ${callback}`,
typeof callback === 'function'
);
}
Expand Down
12 changes: 4 additions & 8 deletions packages/@ember/-internals/glimmer/lib/modifiers/on.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,11 @@ export class OnModifierState {
this.eventName = eventName;
this.shouldUpdate = true;
}
if (DEBUG) {
const debug = args.positional.at(1) && (<any>args.positional.at(1)).debug();
const value = args.positional.at(1) && args.positional.at(1).value();
assert(
`You must pass a function as the second argument to the \`on\` modifier, you passed ${debug} to \`on\` but it was ${value}`,
value !== undefined && typeof value === 'function'
);
}

assert(
'You must pass a function as the second argument to the `on` modifier',
args.positional.at(1) !== undefined && typeof args.positional.at(1).value() === 'function'
);
let userProvidedCallback = args.positional.at(1).value() as EventListener;
if (userProvidedCallback !== this.userProvidedCallback) {
this.userProvidedCallback = userProvidedCallback;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ moduleFor(
arg1: 'foo',
arg2: 'bar',
});
}, /You must pass a function as the `fn` helpers first argument, you passed this.myFunc to `fn` but it was null/);
}, /You must pass a function as the `fn` helpers first argument, you passed null/);
}

'@test asserts if the provided function accesses `this` without being bound prior to passing to fn'(
Expand Down