Skip to content

Commit 4f0108f

Browse files
Robert Jacksonkategengler
authored andcommitted
Revert "improve fn & on undefined callback message"
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)
1 parent f18a276 commit 4f0108f

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

packages/@ember/-internals/glimmer/lib/helpers/fn.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,8 @@ function fn({ positional }: CapturedArguments) {
8585
if (DEBUG && typeof callbackRef[INVOKE] !== 'function') {
8686
let callback = callbackRef.value();
8787

88-
const debug = (<any>callbackRef).debug && (<any>callbackRef).debug();
8988
assert(
90-
`You must pass a function as the \`fn\` helpers first argument, you passed ${debug} to \`fn\` but it was ${callback}`,
89+
`You must pass a function as the \`fn\` helpers first argument, you passed ${callback}`,
9190
typeof callback === 'function'
9291
);
9392
}

packages/@ember/-internals/glimmer/lib/modifiers/on.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,11 @@ export class OnModifierState {
100100
this.eventName = eventName;
101101
this.shouldUpdate = true;
102102
}
103-
if (DEBUG) {
104-
const debug = args.positional.at(1) && (<any>args.positional.at(1)).debug();
105-
const value = args.positional.at(1) && args.positional.at(1).value();
106-
assert(
107-
`You must pass a function as the second argument to the \`on\` modifier, you passed ${debug} to \`on\` but it was ${value}`,
108-
value !== undefined && typeof value === 'function'
109-
);
110-
}
111103

104+
assert(
105+
'You must pass a function as the second argument to the `on` modifier',
106+
args.positional.at(1) !== undefined && typeof args.positional.at(1).value() === 'function'
107+
);
112108
let userProvidedCallback = args.positional.at(1).value() as EventListener;
113109
if (userProvidedCallback !== this.userProvidedCallback) {
114110
this.userProvidedCallback = userProvidedCallback;

packages/@ember/-internals/glimmer/tests/integration/helpers/fn-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ moduleFor(
127127
arg1: 'foo',
128128
arg2: 'bar',
129129
});
130-
}, /You must pass a function as the `fn` helpers first argument, you passed this.myFunc to `fn` but it was null/);
130+
}, /You must pass a function as the `fn` helpers first argument, you passed null/);
131131
}
132132

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

0 commit comments

Comments
 (0)