Skip to content

Conversation

kamilogorek
Copy link
Contributor

@kamilogorek kamilogorek commented Sep 13, 2017

Fixes #1037

https://github.com/getsentry/raven-js/pull/1038/files?w=1#diff-05367d6a2553cabeca57c6ca111093fcR34 – this is the only real change, the rest is just prettify catching up with the rest of the files through precommit hook

function getLocationHref() {
if (typeof document === 'undefined' || typeof document.location === 'undefined')
return '';
if (document == null || document.location == null) return '';
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems problematic. What if document isn't defined? Won't accessing it to make a null comparison throw an exception?

Why not do:

if (typeof document === 'undefined' || document.location == null) return '';

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching that. I completely forgot that document is just a reference to window.document and it has to obey the same rules as every other property.

@kamilogorek
Copy link
Contributor Author

Updated

@benvinegar
Copy link
Contributor

Approved, but in the future, we should try to separate autoformatting changes from behavior changes. It's worth having separate PRs.

@kamilogorek kamilogorek merged commit 21daca5 into master Sep 19, 2017
@kamilogorek kamilogorek deleted the nonull-document branch September 19, 2017 10:34
@kamilogorek
Copy link
Contributor Author

I totally missed that @benvinegar, thanks for pointing that out. Fixed, merged code change only and updated PR here #1048

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