Skip to main content

Bug Tracker

Side navigation

#10687 closed bug (fixed)

Opened November 05, 2011 07:04PM UTC

Closed November 14, 2011 05:14PM UTC

Last modified March 08, 2012 08:21PM UTC

jQuery calls the AMD define() global function too early

Reported by: john@e-numera.com Owned by: timmywil
Priority: blocker Milestone: 1.7.1
Component: core Version: 1.7
Keywords: Cc:
Blocked by: Blocking:
Description

Hey guys!

Sorry I didn't discover this until after release. :(

jQuery shouldn't call the global AMD define() function until jQuery is fully defined. By "fully defined" I mean jQuery and all of its core helpers such as jQuery.Deferred, jQuery.Callbacks, etc.

Since jQuery doesn't expose these to AMD as individual modules, other AMD modules have to assume that they are defined when the jQuery object itself is defined.

See jsFiddle: http://jsfiddle.net/unscriptable/GqfFM/

The easiest solution, imho, is to place the call to define() at the very end of the file.

Regards,

-- John "@unscriptable" Hann

Attachments (0)
Change History (8)

Changed November 05, 2011 07:11PM UTC by timmywil comment:1

#10686 is a duplicate of this ticket.

Changed November 05, 2011 07:15PM UTC by timmywil comment:2

component: unfiledcore
milestone: None1.7.1
priority: undecidedblocker
status: newopen

Thanks John! We'll get a fix in for 1.7.1.

I'd like to have tests for as many amd loaders as possible for the next release, including curl.js and require.

Changed November 05, 2011 07:19PM UTC by jrburke comment:3

I would like to discuss this on the amd-implement list first before a patch is applied. Normally an AMD loader needs to wait for the script to be defined for an anonymous module, so I think it may be useful to just standardize on that behavior even for named modules, more consistent execution behavior. I also thinks it makes it easier for libaries to implement calling AMD, less reworking of their codebase.

I will post back with a link to the amd-implement discussion once it gets set up.

Changed November 05, 2011 07:50PM UTC by jrburke comment:4

Link to the amd-implement discussion I just started, for future reference:

https://groups.google.com/group/amd-implement/browse_thread/thread/a2b113e38a42ea01

Changed November 07, 2011 07:00AM UTC by jrburke comment:5

In the amd-implement thread, John makes a good case that an AMD loader should consider the module completely constructed once the factory function has finished. So I worked up the following patch for this ticket:

https://github.com/jquery/jquery/pull/584

Changed November 08, 2011 01:53AM UTC by jrburke comment:6

A new pull request was done for this ticket based on feedback from timmywil:

https://github.com/jquery/jquery/pull/586

This one replaces #584.

Changed November 14, 2011 04:16PM UTC by dmethvin comment:7

owner: → timmywil
status: openassigned

Changed November 14, 2011 05:14PM UTC by jrburke comment:8

resolution: → fixed
status: assignedclosed

Landing pull request 586. Create exports.js for exporting jQuery to window and AMD. Fixes #10687.

More Details:

Changeset: 8bc60bab5dd9747e7ae06c3fdb0c60782d346ff0