Skip to content

Commit

Permalink
Check instanceof instead of toString for DOMException
Browse files Browse the repository at this point in the history
  • Loading branch information
lionel-rowe committed Nov 17, 2024
1 parent 13c3634 commit 4729c92
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ module.exports = function isError(arg) {
return false; // step 1
}

var str = $toString(arg);

if (str === '[object DOMException]') {
if (typeof DOMException === 'function' && arg instanceof DOMException) {
return true;
}

Expand All @@ -48,7 +46,9 @@ module.exports = function isError(arg) {
}

if (!hasToStringTag || !(Symbol.toStringTag in arg)) {
var str = $toString(arg);
return str === '[object Error]' // errors
|| str === '[object DOMException]' // browsers
|| str === '[object DOMError]' // browsers, deprecated
|| str === '[object Exception]'; // sentry
}
Expand Down

0 comments on commit 4729c92

Please sign in to comment.