sindresorhus / screenfull

Simple wrapper for cross-browser usage of the JavaScript Fullscreen API
https://sindresorhus.com/screenfull
MIT License
7.06k stars 698 forks source link

Use global instead of window #59

Closed vitkarpov closed 10 years ago

vitkarpov commented 10 years ago

It's convenient to use global instead of window in commonjs way. There's no sense to use module in nodejs environment but it should can be interpreted anyway.

sindresorhus commented 10 years ago

For CommonJS it's using module.exports, not window: https://github.com/sindresorhus/screenfull.js/blob/46c1db251b1fece41a7097eece969a74100788b1/src/screenfull.js#L145-L146

vitkarpov commented 10 years ago

I think we didn't understand each other. Sorry about that, I'll try to explain one more time.

There is some module, let a.js. Inside the module we have a such line of code: var screenfull = require('screenfull');.

When I use a module in a browser — everything is ok: screenfull works. Now I try to use it in nodejs (certainly, I don't need to use screenfull, but it should be parsed without errors such as it's required inside a).

When I try to require the a module I see such errors:

document is not defined

or

window is not defined

It occurs 'cause of inside screenfull it should be global.document, not just document.

Is it clear now?