Skip to content

Commit

Permalink
use the this argument for jsfunctionapply
Browse files Browse the repository at this point in the history
  • Loading branch information
kealjones-wk committed Oct 20, 2022
1 parent 3990a38 commit b814c35
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/src/util/console_log_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ void Function() startSpyingOnConsoleLogs({
newObject(),
consolePropertyDescriptors[config],
jsify({
'value': allowInterop(([
'value': allowInteropCaptureThis((
self, [
message,
arg1 = _undefined,
arg2 = _undefined,
Expand All @@ -131,7 +132,7 @@ void Function() startSpyingOnConsoleLogs({
final args = [arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10]
..removeWhere((arg) => arg == _undefined);
boundOnLog(format(message, args));
_jsFunctionApply(consoleRefs[config], [message, ...args]);
_jsFunctionApply(consoleRefs[config], [message, ...args], thisArg: self);
})
}),
);
Expand Down Expand Up @@ -185,8 +186,8 @@ class ConsoleConfig {
static const ConsoleConfig all = ConsoleConfig._('all');
}

dynamic _jsFunctionApply(dynamic jsFunction, List<dynamic> args) {
return callMethod(jsFunction, 'apply', [null, jsify(args)]);
dynamic _jsFunctionApply(dynamic jsFunction, List<dynamic> args, {dynamic thisArg}) {
return callMethod(jsFunction, 'apply', [thisArg, jsify(args)]);
}

const _undefined = _Undefined();
Expand Down

0 comments on commit b814c35

Please sign in to comment.