Skip to content

Commit f0cbdf1

Browse files
committed
Event: Don't warn on ajax .load(), only event .load()
Fixes #138 Closes #144 (cherry picked from commit ca716e9)
1 parent 17e6a3a commit f0cbdf1

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/event.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,17 @@ jQuery.each( [ "load", "unload", "error" ], function( _, name ) {
4343

4444
jQuery.fn[ name ] = function() {
4545
var args = Array.prototype.slice.call( arguments, 0 );
46-
migrateWarn( "jQuery.fn." + name + "() is deprecated" );
4746

4847
// If this is an ajax load() the first arg should be the string URL;
4948
// technically this could also be the "Anything" arg of the event .load()
5049
// which just goes to show why this dumb signature has been deprecated!
5150
// jQuery custom builds that exclude the Ajax module justifiably die here.
52-
if ( name === "load" && typeof arguments[ 0 ] === "string" ) {
53-
return oldLoad.apply( this, arguments );
51+
if ( name === "load" && typeof args[ 0 ] === "string" ) {
52+
return oldLoad.apply( this, args );
5453
}
5554

55+
migrateWarn( "jQuery.fn." + name + "() is deprecated" );
56+
5657
args.splice( 0, 0, name );
5758
if ( arguments.length ) {
5859
return this.bind.apply( this, args );

test/event.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ test( "error() event method", function() {
734734
});
735735

736736
test( "load() and unload() event methods", function() {
737-
expect( 4 );
737+
expect( 5 );
738738

739739
expectWarning( "jQuery.fn.load()", function() {
740740
jQuery( "<img />" )
@@ -757,6 +757,16 @@ test( "load() and unload() event methods", function() {
757757
.unload()
758758
.remove();
759759
});
760+
761+
expectNoWarning( "ajax load", function() {
762+
stop();
763+
jQuery( "<div id=load138></div>" )
764+
.appendTo( "#qunit-fixture" )
765+
.load( "not-found.file", function() {
766+
jQuery( "#load138" ).remove();
767+
start();
768+
});
769+
});
760770
});
761771

762772
test( "hover pseudo-event", function() {

0 commit comments

Comments
 (0)