Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

add jquery version load to asyncLoad test helper

  • Loading branch information...
commit 861fdbe8af8de2a1f02eba81544a806487803fcd 1 parent e11f9f6
John Bender johnbender authored

Showing 1 changed file with 24 additions and 0 deletions. Show diff stats Hide diff stats

  1. +24 0 tests/jquery.testHelper.js
24 tests/jquery.testHelper.js
@@ -8,6 +8,21 @@
8 8 // the previous set has completed loading. That is, each require and it's dependencies in a
9 9 // set will be loaded asynchronously, but each set will be run in serial.
10 10 asyncLoad: function( seq ) {
  11 + var results = /[\\?&]jquery=([^&#]*)/.exec( location.search ), version, defaultVersion;
  12 +
  13 + // if the user has defined a version of jquery in the query params
  14 + // get rid of jquery and push the version of jquery we want to load on to
  15 + // the async load stack
  16 + if( results ) {
  17 + defaultVersion = $().jquery;
  18 +
  19 + // make sure the version of jquery that's in the page by default is unloaded
  20 + window.jQuery = window.$ = undefined;
  21 + version = decodeURIComponent(results[results.length - 1].replace(/\+/g, " "));
  22 + if( window.console ) console.log( "!!! Reloading jquery as v" + version );
  23 + seq.unshift( ["order!jquery-" + version] );
  24 + }
  25 +
11 26 require({
12 27 baseUrl: "../../../js"
13 28 });
@@ -19,12 +34,21 @@
19 34 if ( $fixture.length ) {
20 35 QUnit.config.fixture = $fixture.html();
21 36 }
  37 +
22 38 QUnit.start();
23 39 });
  40 +
24 41 return;
25 42 }
26 43
27 44 require( seq[i], function() {
  45 + // NOTE the window.$() because $ is the old version in this context
  46 + // if we're loading jquery check that the jquery version has changed, otherwise
  47 + // warn the user in the console
  48 + if( seq[i][0].indexOf("jquery-") > -1 && window.$().jquery === defaultVersion && window.console ){
  49 + console.log( "!!! The default version === search param version, ie " + defaultVersion);
  50 + }
  51 +
28 52 loadSeq(seq, i + 1);
29 53 });
30 54 }

0 comments on commit 861fdbe

Please sign in to comment.
Something went wrong with that request. Please try again.