]> source.dussan.org Git - jquery.git/commitdiff
Make sure that Opera fires events after an aborted Ajax attempt. Fixes #5787.
authorjeresig <jeresig@gmail.com>
Tue, 12 Jan 2010 15:31:51 +0000 (10:31 -0500)
committerjeresig <jeresig@gmail.com>
Tue, 12 Jan 2010 15:31:51 +0000 (10:31 -0500)
Makefile
src/ajax.js

index fdb57bda428be1bd8fe55c012963cac2f2ff15cb..9221e0881b9bb6978c2abee8208070e8c220765b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -57,7 +57,7 @@ ${JQ}: ${MODULES}
                sed 's/Date:./&'"${DATE}"'/' | \
                ${VER} > ${JQ};
 
-selector: init
+selector: 
        @@echo "Building selector code from Sizzle"
        @@sed '/EXPOSE/r src/sizzle-jquery.js' src/sizzle/sizzle.js > src/selector.js
 
index 193a85ae04075dac0514fd126b1bd4290ff6d854..07e706c4c5fb55b9cb9ceb90d968e5438ee94fa0 100644 (file)
@@ -393,7 +393,9 @@ jQuery.extend({
                        // The request was aborted, clear the interval and decrement jQuery.active
                        if ( !xhr || xhr.readyState === 0 ) {
                                requestDone = true;
-                               xhr.onreadystatechange = jQuery.noop;
+                               if ( xhr ) {
+                                       xhr.onreadystatechange = jQuery.noop;
+                               }
 
                                // Handle the global AJAX counter
                                if ( s.global && ! --jQuery.active ) {
@@ -447,6 +449,22 @@ jQuery.extend({
                        }
                };
 
+               // Override the abort handler, if we can (IE doesn't allow it, but that's OK)
+               // Opera doesn't fire onreadystatechange at all on abort
+               try {
+                       var oldAbort = xhr.abort;
+                       xhr.abort = function() {
+                               oldAbort.call( xhr );
+                               if ( xhr ) {
+                                       xhr.readyState = 0;
+                               }
+                               if ( !requestDone ) {
+                                       complete();
+                               }
+                               onreadystatechange();
+                       };
+               } catch(e) { }
+
                // Timeout checker
                if ( s.async && s.timeout > 0 ) {
                        setTimeout(function() {