[jsscripting] Fix setTimeout/setInterval fails if delay is not provided or null (#19642)

This is fixed by now handling such values in the JS polyfills, making sure a valid number is always passed to the Java layer.

Signed-off-by: Florian Hotze <dev@florianhotze.com>
This commit is contained in:
Florian Hotze
2025-11-12 17:23:30 +01:00
committed by GitHub
parent 4f6c7a0c40
commit 2200916eef
@@ -181,11 +181,15 @@
globalThis.console = console;
globalThis.setTimeout = function (functionRef, delay, ...args) {
ThreadsafeTimers.setIdentifier(console.loggerName);
if (delay === undefined) delay = 0;
if (delay === null) delay = 0;
return ThreadsafeTimers.setTimeout(() => functionRef(...args), delay);
};
globalThis.clearTimeout = ThreadsafeTimers.clearTimeout;
globalThis.setInterval = function (functionRef, delay, ...args) {
ThreadsafeTimers.setIdentifier(console.loggerName);
if (delay === undefined) delay = 0;
if (delay === null) delay = 0;
return ThreadsafeTimers.setInterval(() => functionRef(...args), delay);
};
globalThis.clearInterval = ThreadsafeTimers.clearInterval;