mirror of
https://github.com/danieldemus/openhab-addons
synced 2026-07-29 12:34:21 +02:00
[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:
Generated
Vendored
+4
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user