Add support for registering jQuery as an AMD module. Only does so if the AMD loader indicates it has special allowances for multiple versions of jQuery being loaded in a page.

This commit is contained in:
jrburke
2011-04-16 20:35:18 -07:00
parent 5d70c6d797
commit 0b1c2e642a
3 changed files with 34 additions and 2 deletions

View File

@@ -1,7 +1,19 @@
var jQuery = this.jQuery || "jQuery", // For testing .noConflict()
$ = this.$ || "$",
originaljQuery = jQuery,
original$ = $;
original$ = $,
amdDefined;
/**
* Set up a mock AMD define function for testing AMD registration.
*/
function define(name, dependencies, callback) {
amdDefined = callback();
}
define.amd = {
jQuery: true
};
/**
* Returns an array of elements with the given IDs, eg.

View File

@@ -214,6 +214,12 @@ test("browser", function() {
});
}
test("amdModule", function() {
expect(1);
equals( jQuery, amdDefined, "Make sure defined module matches jQuery" );
});
test("noConflict", function() {
expect(7);
@@ -850,7 +856,7 @@ test("jQuery.each(Object,Function)", function() {
f[i] = "baz";
});
equals( "baz", f.foo, "Loop over a function" );
var stylesheet_count = 0;
jQuery.each(document.styleSheets, function(i){
stylesheet_count++;