Skip to content

Commit c127989

Browse files
committed
Fix for #8421. Makes sure resolveWith can be called with only one parameter.
1 parent 71bd828 commit c127989

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/core.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,8 @@ jQuery.extend({
837837
// resolve with given context and args
838838
resolveWith: function( context, args ) {
839839
if ( !cancelled && !fired && !firing ) {
840+
// make sure args are available (#8421)
841+
args = args || [];
840842
firing = 1;
841843
try {
842844
while( callbacks[ 0 ] ) {

test/unit/core.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ test("jQuery.parseJSON", function(){
916916

917917
test("jQuery._Deferred()", function() {
918918

919-
expect( 10 );
919+
expect( 11 );
920920

921921
var deferred,
922922
object,
@@ -1005,6 +1005,12 @@ test("jQuery._Deferred()", function() {
10051005
deferred.resolveWith( jQuery , [ document ] ).done( function( doc ) {
10061006
ok( this === jQuery && arguments.length === 1 && doc === document , "Test fire context & args" );
10071007
});
1008+
1009+
// #8421
1010+
deferred = jQuery._Deferred();
1011+
deferred.resolveWith().done(function() {
1012+
ok( true, "Test resolveWith can be called with no argument" );
1013+
});
10081014
});
10091015

10101016
test("jQuery.Deferred()", function() {
@@ -1143,16 +1149,16 @@ test("jQuery.sub() - Static Methods", function(){
11431149
}
11441150
});
11451151
Subclass.fn.extend({subClassMethod: function() { return this;}});
1146-
1152+
11471153
//Test Simple Subclass
11481154
ok(Subclass.topLevelMethod() === false, 'Subclass.topLevelMethod thought debug was true');
11491155
ok(Subclass.config.locale == 'en_US', Subclass.config.locale + ' is wrong!');
11501156
same(Subclass.config.test, undefined, 'Subclass.config.test is set incorrectly');
11511157
equal(jQuery.ajax, Subclass.ajax, 'The subclass failed to get all top level methods');
1152-
1158+
11531159
//Create a SubSubclass
11541160
var SubSubclass = Subclass.sub();
1155-
1161+
11561162
//Make Sure the SubSubclass inherited properly
11571163
ok(SubSubclass.topLevelMethod() === false, 'SubSubclass.topLevelMethod thought debug was true');
11581164
ok(SubSubclass.config.locale == 'en_US', SubSubclass.config.locale + ' is wrong!');
@@ -1169,7 +1175,7 @@ test("jQuery.sub() - Static Methods", function(){
11691175
ok(SubSubclass.config.locale == 'es_MX', SubSubclass.config.locale + ' is wrong!');
11701176
ok(SubSubclass.config.test == 'worked', 'SubSubclass.config.test is set incorrectly');
11711177
notEqual(jQuery.ajax, SubSubclass.ajax, 'The subsubclass failed to get all top level methods');
1172-
1178+
11731179
//This shows that the modifications to the SubSubClass did not bubble back up to it's superclass
11741180
ok(Subclass.topLevelMethod() === false, 'Subclass.topLevelMethod thought debug was true');
11751181
ok(Subclass.config.locale == 'en_US', Subclass.config.locale + ' is wrong!');

0 commit comments

Comments
 (0)