-
Notifications
You must be signed in to change notification settings - Fork 41
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
Fix: Don't call methods that aren't available in the node environment #27
Conversation
Can one of the admins verify this patch? |
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.
Thank you for your PR! Please check my comments.
src/js/browser.js
Outdated
var appName = nav.appName.replace(/\s/g, '_'); | ||
var userAgent = nav.userAgent; | ||
if (window && window.navigator) { | ||
var nav = window.navigator; |
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.
Can you please run eslint? Because we're using indent 4 at tui-code-snippet.
src/js/browser.js
Outdated
} | ||
} | ||
else { | ||
browser.node = true |
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 think this is not enough to detect a node. There is process
object to detect it. What do you think?
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.
That’s fair, we don’t have to assume it’s node and it might be out of scope for what this utility is supposed to do. I can skip that and only check if window and navigator exists, and make no assumptions if it doesn’t.
@jung-han Please verify this PR. I leave some comments. |
@jung-han I think this is ready. Once this gets merged and |
@jkeen Sorry for late😢. Thanks for PR! |
I'm using tui-calendar in an ember app, and when loading it on the server it errors out when calling
window.navigator.appName
, sincewindow.navigator
is null in the node environment.This change checks for window and window.navigator, and if those don't exist, it assumes it's the node environment and marks the
browser
object as such.