Skip to content

Commit

Permalink
Revert "improve fn & on undefined callback message"
Browse files Browse the repository at this point in the history
This reverts commit f6f9f52.

The changes landed cause failures in CI (I should have rebased the
branch to make sure that the code still worked after the last few
glimmer-vm updates).

```
[0413/140947.176661:INFO:CONSOLE(52)] "    Failed assertion: Promise rejected during " model is tracked": args.positional.at(...).debug is not a function
TypeError: args.positional.at(...).debug is not a function
    at OnModifierState.updateFromArgs (http://localhost:13141/tests/ember.js:9767:68)
    at OnModifierManager.install (http://localhost:13141/tests/ember.js:10002:13)
    at TransactionImpl.commit (http://localhost:13141/tests/ember.js:48873:19)
    at EnvironmentImpl.commit (http://localhost:13141/tests/ember.js:49009:19)
    at inTransaction (http://localhost:13141/tests/ember.js:49167:13)
    at InteractiveRenderer._renderRoots (http://localhost:13141/tests/ember.js:11540:37)
    at InteractiveRenderer._renderRootsTransaction (http://localhost:13141/tests/ember.js:11601:14)
    at InteractiveRenderer._renderRoot (http://localhost:13141/tests/ember.js:11527:12)
    at InteractiveRenderer._appendDefinition (http://localhost:13141/tests/ember.js:11442:12)
    at InteractiveRenderer.appendOutletView (http://localhost:13141/tests/ember.js:11428:12)", source:  (52)
```

(cherry picked from commit 109566a)
  • Loading branch information
rwjblue authored and kategengler committed Apr 14, 2020
1 parent f18a276 commit 4f0108f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
3 changes: 1 addition & 2 deletions packages/@ember/-internals/glimmer/lib/helpers/fn.ts
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
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
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

0 comments on commit 4f0108f

Please sign in to comment.