]> source.dussan.org Git - jquery.git/commitdiff
Build: fix tests in AMD mode
authorTimmy Willison <timmywillisn@gmail.com>
Tue, 9 Dec 2014 20:39:24 +0000 (15:39 -0500)
committerTimmy Willison <timmywillisn@gmail.com>
Wed, 10 Dec 2014 15:18:59 +0000 (10:18 -0500)
build/tasks/build.js
src/.jshintrc
src/exports/global.js
src/jquery.js
src/outro.js
test/data/testinit.js
test/unit/core.js

index 199f78120b1bbead0c6788b17f8b27e633ffd8f2..3c457d0bffa8bd4838532e66b8b2130bf80ad3da 100644 (file)
@@ -26,7 +26,7 @@ module.exports = function( grunt ) {
                        skipSemiColonInsertion: true,
                        wrap: {
                                startFile: "src/intro.js",
-                               endFile: "src/outro.js"
+                               endFile: [ "src/exports/global.js", "src/outro.js" ]
                        },
                        paths: {
                                sizzle: "../external/sizzle/dist/sizzle"
@@ -61,13 +61,10 @@ module.exports = function( grunt ) {
 
                } else {
 
-                       // Ignore jQuery's exports (the only necessary one)
-                       if ( name !== "jquery" ) {
-                               contents = contents
-                                       .replace( /\s*return\s+[^\}]+(\}\);[^\w\}]*)$/, "$1" )
-                                       // Multiple exports
-                                       .replace( /\s*exports\.\w+\s*=\s*\w+;/g, "" );
-                       }
+                       contents = contents
+                               .replace( /\s*return\s+[^\}]+(\}\);[^\w\}]*)$/, "$1" )
+                               // Multiple exports
+                               .replace( /\s*exports\.\w+\s*=\s*\w+;/g, "" );
 
                        // Remove define wrappers, closure ends, and empty declarations
                        contents = contents
index 3ffebfd5aa5d1623e6608a4c30ab31d7d2164dc2..6e8dcd3db3d4c118e844beb716671988bde1b60a 100644 (file)
@@ -21,7 +21,8 @@
 
        "globals": {
                "jQuery": true,
-               "define": true,
-               "module": true
+               "define": false,
+               "module": false,
+               "noGlobal": true
        }
 }
index 137f5e26b3e9bd9941f7770ea0892027aa24b2e7..067516a7515a63677a247b3a95912712e911a454 100644 (file)
@@ -1,7 +1,3 @@
-define([
-       "../core"
-], function( jQuery ) {
-
 var
        // Map over jQuery in case of overwrite
        _jQuery = window.jQuery,
@@ -24,8 +20,6 @@ jQuery.noConflict = function( deep ) {
 // Expose jQuery and $ identifiers, even in
 // AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
 // and CommonJS for browser emulators (#13566)
-if ( typeof noGlobal === "undefined" ) {
+if ( !noGlobal ) {
        window.jQuery = window.$ = jQuery;
 }
-
-});
index 7c1528b885071427982c06d0aaf725cf51d11ed6..6e646cf42066d1adfbf8717fefc9220ccd21c3b1 100644 (file)
@@ -29,10 +29,9 @@ define([
        "./offset",
        "./dimensions",
        "./deprecated",
-       "./exports/amd",
-       "./exports/global"
+       "./exports/amd"
 ], function( jQuery ) {
 
-return jQuery;
+return (window.jQuery = window.$ = jQuery);
 
 });
index be4600a5cb1cf4bdf3c980493d802aa380fb0394..d792ffb58fa1c15b3dfadfff1ee36d369c07b830 100644 (file)
@@ -1 +1,2 @@
+return jQuery;
 }));
index 9419986fd1a3552283c75e4c433560aa646e3e06..5afc2e370cd243f2b710f92fca74aa984bd3ede4 100644 (file)
@@ -304,7 +304,9 @@ this.loadTests = function() {
                                /**
                                 * Run in noConflict mode
                                 */
-                               jQuery.noConflict();
+                               if ( jQuery.noConflict ) {
+                                       jQuery.noConflict();
+                               }
 
                                // Load the TestSwarm listener if swarmURL is in the address.
                                if ( loadSwarm ) {
index ab6aff0e3d058037e470ba4635e9ef1b6a148b23..2158ee036d59f4b766dc9209ca1e4b5e6c826120 100644 (file)
@@ -226,24 +226,27 @@ test( "globalEval execution after script injection (#7862)", 1, function() {
        ok( window.strictEvalTest - now < 500, "Code executed synchronously" );
 });
 
-test("noConflict", function() {
-       expect(7);
+// This is not run in AMD mode
+if ( jQuery.noConflict ) {
+       test("noConflict", function() {
+               expect(7);
 
-       var $$ = jQuery;
+               var $$ = jQuery;
 
-       strictEqual( jQuery, jQuery.noConflict(), "noConflict returned the jQuery object" );
-       strictEqual( window["jQuery"], $$, "Make sure jQuery wasn't touched." );
-       strictEqual( window["$"], original$, "Make sure $ was reverted." );
+               strictEqual( jQuery, jQuery.noConflict(), "noConflict returned the jQuery object" );
+               strictEqual( window["jQuery"], $$, "Make sure jQuery wasn't touched." );
+               strictEqual( window["$"], original$, "Make sure $ was reverted." );
 
-       jQuery = $ = $$;
+               jQuery = $ = $$;
 
-       strictEqual( jQuery.noConflict(true), $$, "noConflict returned the jQuery object" );
-       strictEqual( window["jQuery"], originaljQuery, "Make sure jQuery was reverted." );
-       strictEqual( window["$"], original$, "Make sure $ was reverted." );
-       ok( $$().pushStack([]), "Make sure that jQuery still works." );
+               strictEqual( jQuery.noConflict(true), $$, "noConflict returned the jQuery object" );
+               strictEqual( window["jQuery"], originaljQuery, "Make sure jQuery was reverted." );
+               strictEqual( window["$"], original$, "Make sure $ was reverted." );
+               ok( $$().pushStack([]), "Make sure that jQuery still works." );
 
-       window["jQuery"] = jQuery = $$;
-});
+               window["jQuery"] = jQuery = $$;
+       });
+}
 
 test("trim", function() {
        expect(13);