Commit
…indow and AMD. Fixes #10687. More Details: - #586 - http://bugs.jquery.com/ticket/10687
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
(function( jQuery ) { | ||
|
||
// Expose jQuery to the global object | ||
window.jQuery = window.$ = jQuery; | ||
|
||
// Expose jQuery as an AMD module, but only for AMD loaders that | ||
// understand the issues with loading multiple versions of jQuery | ||
// in a page that all might call define(). The loader will indicate | ||
// they have special allowances for multiple jQuery versions by | ||
// specifying define.amd.jQuery = true. Register as a named module, | ||
// since jQuery can be concatenated with other files that may use define, | ||
// but not use a proper concatenation script that understands anonymous | ||
// AMD modules. A named AMD is safest and most robust way to register. | ||
// Lowercase jquery is used because AMD module names are derived from | ||
// file names, and jQuery is normally delivered in a lowercase file name. | ||
// Do this after creating the global so that if an AMD module wants to call | ||
// noConflict to hide this version of jQuery, it will work. | ||
if ( typeof define === "function" && define.amd && define.amd.jQuery ) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
davidmurdoch
|
||
define( "jquery", [], function () { return jQuery; } ); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jrburke
Author
Contributor
|
||
} | ||
|
||
})( jQuery ); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
// Expose jQuery to the global object | ||
window.jQuery = window.$ = jQuery; | ||
|
||
})( window ); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module("exports", { teardown: moduleTeardown }); | ||
|
||
test("amdModule", function() { | ||
expect(1); | ||
|
||
equal( jQuery, amdDefined, "Make sure defined module matches jQuery" ); | ||
}); |
I'm curious why this behavior is just handled for jQuery via
define.amd.jQuery
.I know lots of libs that allow multiple versions on a page through some form of
noConflict()
method.