-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
support DOMException via iserror from npm #913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
You don't need an isObject check here. |
// with some tiny modifications | ||
function isError(what) { | ||
var toString = {}.toString.call(what); | ||
return isObject(what) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benvinegar what is this isObject check for? There's no way to override what Object.prototype.toString does. without being an object. (ES2016, @@toStringTag)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As commented: https://github.com/joyent/node/blob/aa3b4b4/lib/util.js#L560
This was just yanked from Node core, so I'm not entirely sure what this is doing. Just standing on top of giants here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, it's a bit mysterious. Node has moved to a special internal isError that cannot be implemented in plain JS, because objects can override the behaviour of Object.prototype.toString via @@toStringTag
Of course legacy JS could still replace Object.prototype.toString.
491bd33
to
27b0622
Compare
27b0622
to
51471ad
Compare
I'd rather just add a line |
@LewisJEllis you already depend on json-stringify-safe |
Closing in favour on #919 |
Before submitting a pull request, please verify the following: