From cbddf5756e07fbbe10bd35d23bb9e9c0c685442a Mon Sep 17 00:00:00 2001 From: Kyle Kelley Date: Wed, 4 Oct 2023 14:08:57 -0700 Subject: fix(jupyter): keep `this` around (#20789) This fixes #20767. We were losing `this` and then when an exception was happening, it didn't show up in the output because we weren't bubbling up exceptions from within a user defined function for displaying. I thought about doing a `.call(object)` but didn't want to get in the way of a bound `this` that a user or library was already putting on the function. --- cli/tools/jupyter/server.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'cli/tools') diff --git a/cli/tools/jupyter/server.rs b/cli/tools/jupyter/server.rs index 2489fcd04..0b8d25c3e 100644 --- a/cli/tools/jupyter/server.rs +++ b/cli/tools/jupyter/server.rs @@ -554,14 +554,13 @@ async fn get_jupyter_display( "Runtime.callFunctionOn", Some(json!({ "functionDeclaration": r#"function (object) { - const display = object[Symbol.for("Jupyter.display")]; - - if (typeof display !== "function") { + if (typeof object[Symbol.for("Jupyter.display")] !== "function") { return null; } try { - return JSON.stringify(display()); + const representation = object[Symbol.for("Jupyter.display")](); + return JSON.stringify(representation); } catch { return null; } -- cgit v1.2.3