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 for non-browser environments #102
Conversation
Hi, this fixes a bug where `document` is undefined in non-browser environment. I saw aacee47 but needed this extra check as well.
We already define |
In the case of Ember.js server-side rendering (ember fastboot), var document = typeof window.document !== 'undefined' ? window.document : {}; |
Sure |
Wouldn't you need to check |
I think you're right. How about this? var hasDocument = !window || typeof window.document !== 'undefined';
var document = hasDocument ? window.document : {}; |
src/screenfull.js
Outdated
@@ -1,7 +1,7 @@ | |||
(function () { | |||
'use strict'; | |||
|
|||
var document = typeof window === 'undefined' ? {} : window.document; | |||
var document = typeof window.document !== 'undefined' ? window.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.
Needs to be:
var document = window && typeof window.document !== 'undefined' ? window.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.
Tak!
this fix broke server environments ReferenceError: window is not defined |
Same here :( |
@EgorLyutov @Tazer can you verify whether this check works for you?
Checking |
@oskarrough yes when changing that it works much better. So it works for me. |
Unfortunately the last change broke some server environments (not the ember fastboot one, I tested). This should make it good again. #102 (comment)
Hi, this fixes a bug where
document
is undefined in non-browser environment.I saw aacee47 but needed this extra check as well.