Fix code in code demo executing twice on mobile (#5037)

* Prevent code from executing twice on touchscreens
This commit is contained in:
hpnrep6
2021-07-16 13:42:09 -04:00
committed by Monica Kozbial
parent 78a5d98c20
commit 926b14b15e

View File

@@ -549,8 +549,14 @@ Code.initLanguage = function() {
/**
* Execute the user's code.
* Just a quick and dirty eval. Catch infinite loops.
* @param {Event} event Event created from listener bound to the function.
*/
Code.runJS = function() {
Code.runJS = function(event) {
// Prevent code from being executed twice on touchscreens.
if (event.type == 'touchend') {
event.preventDefault();
}
Blockly.JavaScript.INFINITE_LOOP_TRAP = 'checkTimeout();\n';
var timeouts = 0;
var checkTimeout = function() {