Skip to content

Commit

Permalink
feat: assign onerror directly if not configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
wqcstrong committed Jun 15, 2023
1 parent eef934c commit 7799aaf
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/plugins/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@ export default class ErrorPlugin implements PageSpyPlugin {
const userErr = window.onerror;
// @ts-ignore
const isConfigurable = delete window.onerror;
if (!isConfigurable) return;
if (!isConfigurable) {
window.onerror = (...args) => {
ErrorPlugin.sendMessage(args[4]);
if (userErr) {
userErr.apply(window, args);
}
};
return;
}

let errorHandler: (this: Window, ev: ErrorEvent) => any;
Object.defineProperty(window, 'onerror', {
Expand Down

0 comments on commit 7799aaf

Please sign in to comment.