-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Don't access document if undefined #383
Conversation
b20d5ad
to
c9e33d4
Compare
@@ -5,6 +5,8 @@ | |||
// since JSON is required to encode the payload | |||
var _Raven = window.Raven, | |||
hasJSON = !!(typeof JSON === 'object' && JSON.stringify), | |||
// Raven can run in contexts where there's no document (react-native) | |||
hasDocument = typeof document !== 'undefined', |
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.
Why not use isUndefined(document)
?
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.
Sure.
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.
On second thought – isUndefined
is declared halfway through the file, and I like the declaration of hasDocument
at the very top in that big var statement.
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.
But it gets hoisted, yo.
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.
I know it does, but it seems gross to assume that a function is hoisted on the very first JavaScript statement in a file.
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.
a59513e
to
769ab0b
Compare
Don't access document if undefined
No description provided.