Skip to content

Commit b5c6fc7

Browse files
committed
Ajax: Don't let onreadystatechange preempt exceptions from xhr.send
Ref 0a6e1c4
1 parent 3680689 commit b5c6fc7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/ajax/xhr.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,12 @@ if ( xhrSupported ) {
174174
callback();
175175
} else {
176176

177-
// Add to the list of active xhr callbacks
178-
xhr.onreadystatechange = callback;
177+
// Register the callback, but delay it in case `xhr.send` throws
178+
xhr.onreadystatechange = function() {
179+
if ( callback ) {
180+
window.setTimeout( callback );
181+
}
182+
};
179183

180184
xhr.send( ( options.hasContent && options.data ) || null );
181185
}

0 commit comments

Comments
 (0)