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 = {}) {
|
function getTimerApi(runtime = {}) {
|
||||||
|
const rawSetTimeout =
|
||||||
|
typeof runtime.setTimeout === "function"
|
||||||
|
? runtime.setTimeout
|
||||||
|
: globalThis.setTimeout;
|
||||||
|
const rawClearTimeout =
|
||||||
|
typeof runtime.clearTimeout === "function"
|
||||||
|
? runtime.clearTimeout
|
||||||
|
: globalThis.clearTimeout;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
setTimeout:
|
setTimeout(...args) {
|
||||||
typeof runtime.setTimeout === "function"
|
return Reflect.apply(rawSetTimeout, globalThis, args);
|
||||||
? runtime.setTimeout.bind(runtime)
|
},
|
||||||
: globalThis.setTimeout.bind(globalThis),
|
clearTimeout(...args) {
|
||||||
clearTimeout:
|
return Reflect.apply(rawClearTimeout, globalThis, args);
|
||||||
typeof runtime.clearTimeout === "function"
|
},
|
||||||
? runtime.clearTimeout.bind(runtime)
|
|
||||||
: globalThis.clearTimeout.bind(globalThis),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user