From ededebe002cde2092ccdbcb13767807b36c2d522 Mon Sep 17 00:00:00 2001 From: OeildeLynx31 Date: Mon, 15 Apr 2024 17:11:27 +0200 Subject: [PATCH] Add the 'async' property to the onload function only when necessary --- src/resources/blocks/events.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/resources/blocks/events.js b/src/resources/blocks/events.js index 7dafc73..318fd3d 100644 --- a/src/resources/blocks/events.js +++ b/src/resources/blocks/events.js @@ -20,7 +20,7 @@ function register() { //helpUrl: "#fullscreen", }, (block) => { const BLOCKS = javascriptGenerator.statementToCode(block, 'BLOCKS'); - return `async function onload() {\n${BLOCKS}}`; + return `${BLOCKS.indexOf('await') > -1 ? 'async' : ''} function onload() {\n${BLOCKS}}`; }) // setInterval