Permalink
Browse files

Make sure that the require callback is fired even if the file has alr…

…eady been loaded.
  • Loading branch information...
1 parent 0ba7433 commit 2c34462b62b7d7f3fb9bd0b86db6fbc4821aa9be @jeresig jeresig committed Dec 17, 2009
Showing with 6 additions and 1 deletion.
  1. +6 −1 src/core.js
View
7 src/core.js
@@ -447,7 +447,7 @@ jQuery.extend({
// We only need to run the callback after all the scripts have loaded
jQuery.require( arguments[i], i === length - 1 ? callback :
// Make sure that a blank callback is provided to ensure async transport
- typeof callback === "function" ? function(){} : null );
+ jQuery.isFunction( callback ) ? function(){} : null );
}
return;
@@ -460,6 +460,11 @@ jQuery.extend({
options.url = jQuery.require.urlFilter( options.url );
if ( !options || jQuery.requireCache[ options.url ] != null ) {
+ // File is already loaded, immediately execute the callback
+ if ( jQuery.isFunction( callback ) ) {
+ callback();
+ }
+
return;
}

0 comments on commit 2c34462

Please sign in to comment.