filepicker / filepicker-js

Filepicker javascript library
38 stars 15 forks source link

window is not defined #30

Open igorrKurr opened 8 years ago

igorrKurr commented 8 years ago

Hey! I've tried to use it with react isomorphic tools, and got that error. Is it possible to mock window somehow? Or make it agnostic?

ZeroCho commented 8 years ago

+1 please make this compatible with react(server-side-rendering) and webpack. I think wrapping entire codes with

function(window) {
// codes here
}(typeof window === 'object' ? window : this)

will suffice

leebenson commented 8 years ago

Apologies for the bump, but IMO this is super important. Plenty of iso environments these days with React + Angular that this currently kills.

sheerun commented 8 years ago

Until #48 is merged, you can use sheerun/filepicker-js#isomorphic as npm dependency for isomorphic apps (or when testing with mocha)

osdiab commented 7 years ago

Additionally this is causing our tests to fail; using jsdom-global to simulate the DOM in test environments, we find that this code causes a failure:

Code

require("jsdom-global")();
require("filepicker-js");

Error

ReferenceError: filepicker is not defined
    at Object.<anonymous> (/node_modules/filepicker-js/dist/filepicker.js:65:1)

The reason is that it is attaching itself to window automatically (that fails if we don't use jsdom-global), and then even with JSDOM window isn't a global in Node so it doesn't see it globally.

This relates to #56