Skip to content

Commit

Permalink
improve createOnErrorHandler typings
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislav-atr committed May 10, 2023
1 parent 198448c commit 6cc6597
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/helpers/create-on-error-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
* @param rid - unique identifier of scriptlet
* @returns window.onerror handler
*/
export function createOnErrorHandler(context: Window, rid: string): OnErrorEventHandler {
export function createOnErrorHandler(rid: string): OnErrorEventHandler {
// eslint-disable-next-line consistent-return
const nativeOnError = window.onerror;
return function onError(error, ...args) {
if (typeof error === 'string' && error.indexOf(rid) !== -1) {
return true;
}
if (nativeOnError instanceof Function) {
return nativeOnError.apply(context, [error, ...args]);
return nativeOnError.apply(window, [error, ...args]);
}
return false;
};
Expand Down

0 comments on commit 6cc6597

Please sign in to comment.