From 3bc36d6130e8baa96b050b4391914a004f3d239f Mon Sep 17 00:00:00 2001 From: Neil Fraser Date: Tue, 1 Mar 2022 10:11:19 -0800 Subject: [PATCH] Stop using createPrimitive function Not just deprecated, actually removed. --- demos/interpreter/step-execution.html | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/demos/interpreter/step-execution.html b/demos/interpreter/step-execution.html index 03e62aed6..606f647cc 100644 --- a/demos/interpreter/step-execution.html +++ b/demos/interpreter/step-execution.html @@ -29,8 +29,7 @@ where %1 is the block id. The call to highlightBlock() will highlight the identified block and set the variable highlightPause to true.

-

"Parse JavaScript" will generate the code and load it into the interpreter. Then, each press of the - "Step JavaScript" button will run the interpreter one step until the highlightPause is true. +

Each press of the "Step JavaScript" button will run the interpreter one step until the highlightPause is true. That is, until highlightBlock() has highlighted the block that will be executed on the next step.

More info on running code with JS Interpreter

@@ -151,15 +150,16 @@ function initApi(interpreter, globalObject) { // Add an API function for the alert() block, generated for "text_print" blocks. - interpreter.setProperty(globalObject, 'alert', - interpreter.createNativeFunction(function(text) { + var wrapper = function alert(text) { text = arguments.length ? text : ''; outputArea.value += '\n' + text; - })); + }; + interpreter.setProperty(globalObject, 'alert', + interpreter.createNativeFunction(wrapper)); // Add an API function for the prompt() block. - var wrapper = function(text) { - return interpreter.createPrimitive(prompt(text)); + var wrapper = function prompt(text) { + return window.prompt(text); }; interpreter.setProperty(globalObject, 'prompt', interpreter.createNativeFunction(wrapper)); @@ -167,7 +167,7 @@ // Add an API function for highlighting blocks. var wrapper = function(id) { id = String(id || ''); - return interpreter.createPrimitive(highlightBlock(id)); + return highlightBlock(id); }; interpreter.setProperty(globalObject, 'highlightBlock', interpreter.createNativeFunction(wrapper)); @@ -209,7 +209,7 @@ // In a timeout to allow the outputArea.value to reset first. setTimeout(function() { alert('Ready to execute the following code\n' + - '===================================\n' + latestCode); + '===================================\n' + latestCode); highlightPause = true; stepCode(); }, 1);