Skip to content
Permalink
Browse files

Make sure original context is maintained and not the deep extended on…

…e. Fixes #5924.
  • Loading branch information
jeresig committed Jan 25, 2010
1 parent f91b944 commit 1a14a38ff77839b2a71fbc3f3c0890ebe62438c7
Showing with 22 additions and 1 deletion.
  1. +1 −1 src/ajax.js
  2. +21 −0 test/unit/ajax.js
@@ -206,7 +206,7 @@ jQuery.extend({
var s = jQuery.extend(true, {}, jQuery.ajaxSettings, origSettings);

var jsonp, status, data,
callbackContext = s.context || s,
callbackContext = origSettings && origSettings.context || s,
type = s.type.toUpperCase();

// convert data if not already a string
@@ -180,6 +180,27 @@ test("Ajax events with context", function() {
});
});

test("jQuery.ajax context modification", function() {
expect(1);

stop();

var obj = {}

jQuery.ajax({
url: url("data/name.html"),
context: obj,
beforeSend: function(){
this.test = "foo";
},
complete: function() {
start();
}
});

equals( obj.test, "foo", "Make sure the original object is maintained." );
});

test("jQuery.ajax() - disabled globals", function() {
expect( 3 );
stop();

0 comments on commit 1a14a38

Please sign in to comment.
You can’t perform that action at this time.