Merge branch 'fixAdjacentTests' of https://github.com/jitter/jquery into jitter-fixAd...
authorJohn Resig <jeresig@gmail.com>
Tue, 9 Nov 2010 20:49:07 +0000 (15:49 -0500)
committerJohn Resig <jeresig@gmail.com>
Tue, 9 Nov 2010 20:49:07 +0000 (15:49 -0500)
src/ajax.js
src/core.js
test/unit/ajax.js
test/unit/selector.js

index 9195bcc..d10b931 100644 (file)
@@ -463,10 +463,11 @@ jQuery.extend({
                try {
                        var oldAbort = xhr.abort;
                        xhr.abort = function() {
-                               // xhr.abort in IE7 is not a native JS function
-                               // and does not have a call property
-                               if ( xhr && oldAbort.call ) {
-                                       oldAbort.call( xhr );
+                               if ( xhr ) {
+                                       // oldAbort has no call property in IE7 so
+                                       // just do it this way, which works in all
+                                       // browsers
+                                       Function.prototype.call.call( oldAbort, xhr );
                                }
 
                                onreadystatechange( "abort" );
index 8940ada..9e1bfc6 100644 (file)
@@ -417,18 +417,21 @@ jQuery.extend({
                        // If there are functions bound, to execute
                        if ( readyList ) {
                                // Execute all of them
-                               var fn, i = 0;
-                               while ( (fn = readyList[ i++ ]) ) {
-                                       fn.call( document, jQuery );
-                               }
+                               var fn,
+                                       i = 0,
+                                       ready = readyList;
 
                                // Reset the list of functions
                                readyList = null;
-                       }
 
-                       // Trigger any bound ready events
-                       if ( jQuery.fn.trigger ) {
-                               jQuery( document ).trigger( "ready" ).unbind( "ready" );
+                               while ( (fn = ready[ i++ ]) ) {
+                                       fn.call( document, jQuery );
+                               }
+
+                               // Trigger any bound ready events
+                               if ( jQuery.fn.trigger ) {
+                                       jQuery( document ).trigger( "ready" ).unbind( "ready" );
+                               }
                        }
                }
        },
index b2e51fb..4ce14c2 100644 (file)
@@ -137,7 +137,7 @@ test(".load()) - 404 error callbacks", function() {
 });
 
 test("jQuery.ajax() - abort", function() {
-       expect( 6 );
+       expect( 8 );
        stop();
 
        jQuery('#foo').ajaxStart(function(){
@@ -157,7 +157,10 @@ test("jQuery.ajax() - abort", function() {
                complete: function(){ ok(true, "complete"); }
        });
 
+       equals( xhr.readyState, 1, "XHR readyState indicates successful dispatch" );
+
        xhr.abort();
+       equals( xhr.readyState, 0, "XHR readyState indicates successful abortion" );
 });
 
 test("Ajax events with context", function() {
index 9a65d98..6ec20bc 100644 (file)
@@ -237,7 +237,7 @@ test("child and adjacent", function() {
 });
 
 test("attributes", function() {
-       expect(35);
+       expect(39);
        t( "Attribute Exists", "a[title]", ["google"] );
        t( "Attribute Exists", "*[title]", ["google"] );
        t( "Attribute Exists", "[title]", ["google"] );
@@ -275,8 +275,16 @@ test("attributes", function() {
        t( "Attribute Contains", "a[href *= 'google']", ["google","groups"] );
        t( "Attribute Is Not Equal", "#ap a[hreflang!='en']", ["google","groups","anchor1"] );
 
-       var opt = document.getElementById("option1a");
-       ok( (window.Sizzle || window.jQuery.find).matchesSelector( opt, "[id*=option1][type!=checkbox]" ), "Attribute Is Not Equal Matches" );
+       var opt = document.getElementById("option1a"),
+               match = (window.Sizzle || window.jQuery.find).matchesSelector;
+
+       opt.setAttribute("test", "");
+
+       ok( match( opt, "[id*=option1][type!=checkbox]" ), "Attribute Is Not Equal Matches" );
+       ok( match( opt, "[id*=option1]" ), "Attribute With No Quotes Contains Matches" );
+       ok( match( opt, "[test=]" ), "Attribute With No Quotes No Content Matches" );
+       ok( match( opt, "[id=option1a]" ), "Attribute With No Quotes Equals Matches" );
+       ok( match( document.getElementById("simon1"), "a[href*=#]" ), "Attribute With No Quotes Href Contains Matches" );
 
        t("Empty values", "#select1 option[value='']", ["option1a"]);
        t("Empty values", "#select1 option[value!='']", ["option1b","option1c","option1d"]);