diff --git a/build/tasks/build.js b/build/tasks/build.js index 481a4d8f7..f59a3340b 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -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 diff --git a/src/core/parseHTML.js b/src/core/parseHTML.js index 54016a4c1..c441b2b92 100644 --- a/src/core/parseHTML.js +++ b/src/core/parseHTML.js @@ -1,6 +1,8 @@ define([ "../core", "./var/rsingleTag", + "./support", + "../manipulation" // buildFragment ], function( jQuery, rsingleTag, support ) { diff --git a/src/core/support.js b/src/core/support.js index fe3d6c218..d3ed33c04 100644 --- a/src/core/support.js +++ b/src/core/support.js @@ -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; }); diff --git a/src/exports/global.js b/src/exports/global.js index d96cc4d93..5d4d050fe 100644 --- a/src/exports/global.js +++ b/src/exports/global.js @@ -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; } - -}); diff --git a/src/jquery.js b/src/jquery.js index d3857e955..1d56c4b15 100644 --- a/src/jquery.js +++ b/src/jquery.js @@ -28,10 +28,9 @@ define([ "./offset", "./dimensions", "./deprecated", - "./exports/amd", - "./exports/global" + "./exports/amd" ], function( jQuery ) { -return jQuery; +return (window.jQuery = window.$ = jQuery); }); diff --git a/src/outro.js b/src/outro.js index be4600a5c..d792ffb58 100644 --- a/src/outro.js +++ b/src/outro.js @@ -1 +1,2 @@ +return jQuery; })); diff --git a/test/data/testinit.js b/test/data/testinit.js index cb7ddf3ca..9b3caba93 100644 --- a/test/data/testinit.js +++ b/test/data/testinit.js @@ -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 ) { diff --git a/test/unit/core.js b/test/unit/core.js index 783a7462e..ce3c3184d 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -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);