Skip to content
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

Merged
merged 1 commit into from
Sep 16, 2015
Merged

Don't access document if undefined #383

merged 1 commit into from
Sep 16, 2015

Conversation

benvinegar
Copy link
Contributor

No description provided.

@@ -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',
Copy link
Contributor

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)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benvinegar benvinegar force-pushed the no-document branch 3 times, most recently from a59513e to 769ab0b Compare September 16, 2015 19:48
benvinegar added a commit that referenced this pull request Sep 16, 2015
Don't access document if undefined
@benvinegar benvinegar merged commit 4db9b1d into master Sep 16, 2015
@mattrobenolt mattrobenolt deleted the no-document branch October 22, 2015 22:33
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants