Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Document window requirement for CommonJS environment #296

Open
timmywil opened this Issue May 8, 2013 · 7 comments

Comments

Projects
None yet
5 participants
Owner

timmywil commented May 8, 2013

See http://bugs.jquery.com/ticket/13768.

jQuery needs a window object in order to be initialized correctly, but some environments do not have an available window object by default. For example, when requiring jQuery in a Node environment using jsdom:

// Define window
var window = jsdom.jsdom().createWindow();
// Require jQuery and pass in the created window
var $ = require("jquery")( window );
Member

kswedberg commented May 8, 2013

Where do you suggest we document this?

Owner

timmywil commented May 8, 2013

I'm not sure. We'll discuss in the next meeting though.

Owner

timmywil commented Jun 27, 2013

I forgot about this for a while. I've added it to the agenda for the next meeting.

Owner

timmywil commented Jul 4, 2013

@kswedberg Per the meeting, what do you think about adding another page? Perhaps there are other issues that don't really fit?

Owner

timmywil commented Jul 4, 2013

Also, the issue has been updated. jQuery will be included in CommonJS by passing in a window.

What about the use case of jQuery without a window? jQuery provides $.ajax which some very large frameworks require (like Backbone.js). If we could do

Backbone.$ = require('jquery')

And, at least get Backbone.$.ajax running we could unit test Backbone.js outside of the browser...

Member

AurelioDeRosa commented Oct 6, 2015

@timmywil A long time is passed since this issue was opened. What's the current status of jQuery in that regard?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment