From: Timmy Willison Date: Thu, 29 Aug 2013 20:18:17 +0000 (-0400) Subject: Pass all tests (and load Sizzle fixture correctly) when loading with AMD X-Git-Tag: 2.1.0-beta1~62 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=004c1fc5bb40ae8dfec18d6719534abad636b7e8;p=jquery.git Pass all tests (and load Sizzle fixture correctly) when loading with AMD --- diff --git a/src/ajax/load.js b/src/ajax/load.js index e9c21ef16..b54750e0a 100644 --- a/src/ajax/load.js +++ b/src/ajax/load.js @@ -2,7 +2,10 @@ define([ "../core", "../ajax", "../traversing", - "../selector" + "../manipulation", + "../selector", + // Optional event/alias dependency + "../event/alias" ], function( jQuery ) { // Keep a copy of the old load method diff --git a/src/css.js b/src/css.js index caad0076a..4ac7dfbce 100644 --- a/src/css.js +++ b/src/css.js @@ -8,7 +8,9 @@ define([ "./core/swap", "./core/ready", "./selector", // contains - "./support" + "./support", + // Optional + "./offset" ], function( jQuery, pnum, cssExpand, isHidden, defaultDisplay, data_priv ) { var curCSS, // swappable if display is none or starts with table except "table", "table-cell", or "table-caption" @@ -467,7 +469,6 @@ jQuery(function() { // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084 // getComputedStyle returns percent when specified for top/left/bottom/right // rather than make the css module depend on the offset module, we just check for it here - // TODO: Optional dependency on offset if ( !jQuery.support.pixelPosition && jQuery.fn.position ) { jQuery.each( [ "top", "left" ], function( i, prop ) { jQuery.cssHooks[ prop ] = { diff --git a/test/.jshintrc b/test/.jshintrc index 75c50eeeb..f974f8e4b 100644 --- a/test/.jshintrc +++ b/test/.jshintrc @@ -21,6 +21,7 @@ "wsh": true, "globals": { + "require": false, "DOMParser": false, "QUnit": false, "ok": false, diff --git a/test/data/testrunner.js b/test/data/testrunner.js index 072de9bba..80e7bb6c9 100644 --- a/test/data/testrunner.js +++ b/test/data/testrunner.js @@ -16,7 +16,13 @@ var Sizzle = Sizzle || jQuery.find, qunitModule = QUnit.module, qunitTest = QUnit.test; -this.testSubproject = function( label, url, risTests ) { +/** + * Test a subproject with its own fixture + * @param {String} label Project name + * @param {String} url Test folder location + * @param {RegExp} risTests To filter script sources + */ +this.testSubproject = function( label, url, risTests, complete ) { var sub, fixture, fixtureHTML, fixtureReplaced = false; @@ -65,7 +71,8 @@ this.testSubproject = function( label, url, risTests ) { throw new Error( "Could not load: " + url + " (" + status + ")" ); }, success: function( data, status, jqXHR ) { - var page = originaljQuery.parseHTML( + var sources = [], + page = originaljQuery.parseHTML( // replace html/head with dummy elements so they are represented in the DOM ( data || "" ).replace( /<\/?((!DOCTYPE|html|head)\b.*?)>/gi, "[$1]" ), document, @@ -78,18 +85,23 @@ this.testSubproject = function( label, url, risTests ) { page = originaljQuery( page ); // Include subproject tests - page.filter("script[src]").add( page.find("script[src]") ).each(function() { - var src = originaljQuery( this ).attr("src"), - html = ""; + page.filter("script[src]").add( page.find("script[src]") ).map(function() { + var src = originaljQuery( this ).attr("src"); if ( risTests.test( src ) ) { - if ( originaljQuery.isReady ) { - originaljQuery("head").first().append( html ); - } else { - document.write( html ); - } + sources.push( src ); } }); + // Ensure load order + (function loadDep() { + var dep = sources.shift(); + if ( dep ) { + require( [ url + dep ], loadDep ); + } else if ( complete ) { + complete(); + } + })(); + // Get the fixture, including content outside of #qunit-fixture fixture = page.find("[id='qunit-fixture']"); fixtureHTML = fixture.html(); @@ -156,6 +168,11 @@ this.Globals = (function() { }; })(); + +/** + * QUnit hooks + */ + // Sandbox start for great justice (function() { var oldStart = window.start; @@ -164,9 +181,6 @@ this.Globals = (function() { }; })(); -/** - * QUnit hooks - */ (function() { // Store the old counts so that we only assert on tests that have actually leaked, // instead of asserting every time a test has leaked sometime in the past diff --git a/test/index.html b/test/index.html index 013548558..3636df471 100644 --- a/test/index.html +++ b/test/index.html @@ -11,44 +11,58 @@ - - - + + + - +