Skip to content

Commit

Permalink
Never use the XML as parsed by the XHR instance. Use raw text instead…
Browse files Browse the repository at this point in the history
… and let the ajax conversion logic do the trick. -20 min/gzipped. Fixes #13276. Unit test added.
  • Loading branch information
jaubourg committed Jan 21, 2013
1 parent df47eb7 commit b83081b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
9 changes: 1 addition & 8 deletions src/ajax/xhr.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ if ( xhrSupported ) {
var status, var status,
statusText, statusText,
responseHeaders, responseHeaders,
responses, responses;
xml;


// Firefox throws exceptions when accessing properties // Firefox throws exceptions when accessing properties
// of an xhr when a network error occurred // of an xhr when a network error occurred
Expand Down Expand Up @@ -136,14 +135,8 @@ if ( xhrSupported ) {
} else { } else {
responses = {}; responses = {};
status = xhr.status; status = xhr.status;
xml = xhr.responseXML;
responseHeaders = xhr.getAllResponseHeaders(); responseHeaders = xhr.getAllResponseHeaders();


// Construct response list
if ( xml && xml.documentElement /* #4958 */ ) {
responses.xml = xml;
}

// When requesting binary data, IE6-9 will throw an exception // When requesting binary data, IE6-9 will throw an exception
// on any attempt to access responseText (#11426) // on any attempt to access responseText (#11426)
if ( typeof xhr.responseText === "string" ) { if ( typeof xhr.responseText === "string" ) {
Expand Down
16 changes: 16 additions & 0 deletions test/unit/ajax.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1483,6 +1483,22 @@ module( "ajax", {


}); });


ajaxTest( "#13276 - jQuery.ajax() - compatibility between XML documents from ajax requests and parsed string", 1, {
url: "data/dashboard.xml",
dataType: "xml",
success: function( ajaxXML ) {
var parsedXML = jQuery( jQuery.parseXML("<tab title=\"Added\">blibli</tab>") ).find("tab");
ajaxXML = jQuery( ajaxXML );
try {
ajaxXML.find("infowindowtab").append( parsedXML );
} catch( e ) {
strictEqual( e, undefined, "error" );
return;
}
strictEqual( ajaxXML.find("tab").length, 3, "Parsed node was added properly" );
}
});

//----------- jQuery.ajaxPrefilter() //----------- jQuery.ajaxPrefilter()


ajaxTest( "jQuery.ajaxPrefilter() - abort", 1, { ajaxTest( "jQuery.ajaxPrefilter() - abort", 1, {
Expand Down

0 comments on commit b83081b

Please sign in to comment.