mirror of
https://github.com/Youzini-afk/ST-Bionic-Memory-Ecology.git
synced 2026-05-15 22:30:38 +08:00
Fix hide scheduler timer binding
This commit is contained in:
@@ -13,15 +13,22 @@ const hideState = {
|
||||
};
|
||||
|
||||
function getTimerApi(runtime = {}) {
|
||||
const rawSetTimeout =
|
||||
typeof runtime.setTimeout === "function"
|
||||
? runtime.setTimeout
|
||||
: globalThis.setTimeout;
|
||||
const rawClearTimeout =
|
||||
typeof runtime.clearTimeout === "function"
|
||||
? runtime.clearTimeout
|
||||
: globalThis.clearTimeout;
|
||||
|
||||
return {
|
||||
setTimeout:
|
||||
typeof runtime.setTimeout === "function"
|
||||
? runtime.setTimeout.bind(runtime)
|
||||
: globalThis.setTimeout.bind(globalThis),
|
||||
clearTimeout:
|
||||
typeof runtime.clearTimeout === "function"
|
||||
? runtime.clearTimeout.bind(runtime)
|
||||
: globalThis.clearTimeout.bind(globalThis),
|
||||
setTimeout(...args) {
|
||||
return Reflect.apply(rawSetTimeout, globalThis, args);
|
||||
},
|
||||
clearTimeout(...args) {
|
||||
return Reflect.apply(rawClearTimeout, globalThis, args);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user