]> 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>
Tue, 9 Dec 2014 20:39:24 +0000 (15:39 -0500)
build/tasks/build.js
src/core/parseHTML.js
src/core/support.js
src/exports/global.js
src/jquery.js
src/outro.js
test/data/testinit.js
test/unit/core.js

index 481a4d8f7ae3af9e658a51e3579161ef91fc6d70..f59a3340b8e5c9e4282f347327e216dc2dadeb05 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 54016a4c1c5d5c8d7bc7ee8281f504ca1a1613e8..c441b2b92ddb2d787ed7e4cb7d11072bafb6ed3a 100644 (file)
@@ -1,6 +1,8 @@
 define([
        "../core",
        "./var/rsingleTag",
+       "./support",
+
        "../manipulation" // buildFragment
 ], function( jQuery, rsingleTag, support ) {
 
index fe3d6c21863d98defb183b3e3baff0a665efde7b..d3ed33c040dd17dac4789831181948881b6bd89c 100644 (file)
@@ -1,6 +1,8 @@
 define([
        "../var/support"
-], function( jQuery, support ) {
+], function( support ) {
        // window.document is used here as it's before the sandboxed document
        support.createHTMLDocument = !!window.document.implementation.createHTMLDocument;
+
+       return support;
 });
index d96cc4d93817e6a7fee8511fc28e652f61316017..5d4d050fe761ddc140d606cc1a6460b1706bb8fe 100644 (file)
@@ -1,7 +1,3 @@
-define([
-       "../core"
-], function( jQuery ) {
-
 var
        // Map over jQuery in case of overwrite
        _jQuery = window.jQuery,
@@ -27,5 +23,3 @@ jQuery.noConflict = function( deep ) {
 if ( !noGlobal ) {
        window.jQuery = window.$ = jQuery;
 }
-
-});
index d3857e95566a8b2b048e5ba1738174b9ee0e8795..1d56c4b15208f2cb36487d2ff0cb059e7e51d7bd 100644 (file)
@@ -28,10 +28,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 cb7ddf3ca8a28f11c67b38b15884491799d4a5cb..9b3caba937571ce6edd10341d618f2ffeb4fc85c 100644 (file)
@@ -301,7 +301,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 783a7462ed545c80f1607b305bf135b86021c575..ce3c3184de87012113b63f08615d875c82f6bc7a 100644 (file)
@@ -234,24 +234,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);