File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed
Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -935,6 +935,20 @@ function doScrollCheck() {
935935 jQuery . ready ( ) ;
936936}
937937
938+ // Expose jQuery as an AMD module, but only for AMD loaders that
939+ // understand the issues with loading multiple versions of jQuery
940+ // in a page that all might call define(). The loader will indicate
941+ // they have special allowances for multiple jQuery versions by
942+ // specifying define.amd.jQuery = true. Register as a named module,
943+ // since jQuery can be concatenated with other files that may use define,
944+ // but not use a proper concatenation script that understands anonymous
945+ // AMD modules. A named AMD is safest and most robust way to register.
946+ // Lowercase jquery is used because AMD module names are derived from
947+ // file names, and jQuery is normally delivered in a lowercase file name.
948+ if ( typeof define === "function" && define . amd && define . amd . jQuery ) {
949+ define ( "jquery" , [ ] , function ( ) { return jQuery ; } ) ;
950+ }
951+
938952return jQuery ;
939953
940954} ) ( ) ;
Original file line number Diff line number Diff line change 11var jQuery = this . jQuery || "jQuery" , // For testing .noConflict()
22 $ = this . $ || "$" ,
33 originaljQuery = jQuery ,
4- original$ = $ ;
4+ original$ = $ ,
5+ amdDefined ;
6+
7+ /**
8+ * Set up a mock AMD define function for testing AMD registration.
9+ */
10+ function define ( name , dependencies , callback ) {
11+ amdDefined = callback ( ) ;
12+ }
13+
14+ define . amd = {
15+ jQuery : true
16+ } ;
517
618/**
719 * Returns an array of elements with the given IDs, eg.
Original file line number Diff line number Diff line change @@ -225,6 +225,12 @@ test("browser", function() {
225225} ) ;
226226}
227227
228+ test ( "amdModule" , function ( ) {
229+ expect ( 1 ) ;
230+
231+ equals ( jQuery , amdDefined , "Make sure defined module matches jQuery" ) ;
232+ } ) ;
233+
228234test ( "noConflict" , function ( ) {
229235 expect ( 7 ) ;
230236
You can’t perform that action at this time.
0 commit comments