1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-10-04 16:47:15 +02:00

Drop requestIdleCallback from globals

Related discussion:
- https://github.com/gorhill/uBlock/pull/3839

`requestIdleCallback` can be assumed always present on
browser-related platforms.
This commit is contained in:
Raymond Hill 2021-08-19 07:31:27 -04:00
parent 68675ed1cd
commit 19160f9018
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
2 changed files with 4 additions and 19 deletions

View File

@ -382,8 +382,8 @@ const onFilterChanged = (( ) => {
};
return function() {
if ( timer !== undefined ) { globals.cancelIdleCallback(timer); }
timer = globals.requestIdleCallback(process, { timeout: 773 });
if ( timer !== undefined ) { self.cancelIdleCallback(timer); }
timer = self.requestIdleCallback(process, { timeout: 773 });
};
})();
@ -555,8 +555,8 @@ const onTextChanged = (( ) => {
};
return function(now) {
if ( timer !== undefined ) { globals.cancelIdleCallback(timer); }
timer = now ? process() : globals.requestIdleCallback(process, { timeout: 57 });
if ( timer !== undefined ) { self.cancelIdleCallback(timer); }
timer = now ? process() : self.requestIdleCallback(process, { timeout: 57 });
};
})();

View File

@ -35,21 +35,6 @@ const globals = (( ) => {
// jshint ignore:end
})();
// https://en.wikipedia.org/wiki/.invalid
if ( globals.location === undefined ) {
globals.location = new URL('https://ublock0.invalid/');
}
// https://developer.mozilla.org/en-US/docs/Web/API/Window/requestIdleCallback
if ( globals.requestIdleCallback === undefined ) {
globals.requestIdleCallback = function(callback) {
return globals.setTimeout(callback, 1);
};
globals.cancelIdleCallback = function(handle) {
return globals.clearTimeout(handle);
};
}
/******************************************************************************/
export default globals;