KyleAMathews / element-resize-event

Library to make it easy to listen for element resize events
http://kyleamathews.github.io/element-resize-event/
MIT License
175 stars 44 forks source link

element-resize-event pollutes nodejs environment with "document" and "window" objects #4

Closed stefanoverna closed 9 years ago

stefanoverna commented 9 years ago

window and document are declared without the var keyword:

https://github.com/KyleAMathews/element-resize-event/blob/master/index.js#L2

This has an equivalent effect to this line:

global.window = {}

It's a best practice for npm packages to not pollute the global namespace. In particular, plenty of other modules use a rough check on window to tell if it's a nodejs environment or not, and this line invalidates the check.

Would you mind updating the package with this fix?

KyleAMathews commented 9 years ago

Oops! Thanks! I code in Coffeescript for the most part so miss JS stuff like this sometimes. Pushed out a 2.0.2 release with the fix.