Removes unnecessary test and ensures getResponseHeader returns null if the header...
[jquery.git] / src / core.js
index 25ef22d..f116ef4 100644 (file)
@@ -19,12 +19,8 @@ var jQuery = function( selector, context ) {
        // (both of which we optimize for)
        quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,
 
-       // Is it a simple selector
-       isSimple = /^.[^:#\[\.,]*$/,
-
        // Check if a string has a non-whitespace character in it
        rnotwhite = /\S/,
-       rwhite = /\s/,
 
        // Used for trimming whitespace
        trimLeft = /^\s+/,
@@ -63,6 +59,9 @@ var jQuery = function( selector, context ) {
        // The deferred used on DOM ready
        readyList,
 
+       // Promise methods
+       promiseMethods = "then done fail isResolved isRejected promise".split( " " ),
+
        // The ready event handler
        DOMContentLoaded,
 
@@ -580,7 +579,7 @@ jQuery.extend({
 
                        script.type = "text/javascript";
 
-                       if ( jQuery.support.scriptEval ) {
+                       if ( jQuery.support.scriptEval() ) {
                                script.appendChild( document.createTextNode( data ) );
                        } else {
                                script.text = data;
@@ -914,16 +913,18 @@ jQuery.extend({
                        isRejected: failDeferred.isResolved,
                        // Get a promise for this deferred
                        // If obj is provided, the promise aspect is added to the object
-                       promise: function( obj ) {
+                       // (i is used internally)
+                       promise: function( obj , i ) {
                                if ( obj == null ) {
                                        if ( promise ) {
                                                return promise;
                                        }
                                        promise = obj = {};
                                }
-                               jQuery.each( "then done fail isResolved isRejected promise".split( " " ) , function( _ , method ) {
-                                       obj[ method ] = deferred[ method ];
-                               });
+                               i = promiseMethods.length;
+                               while( i-- ) {
+                                       obj[ promiseMethods[ i ] ] = deferred[ promiseMethods[ i ] ];
+                               }
                                return obj;
                        }
 
@@ -1034,9 +1035,8 @@ if ( indexOf ) {
        };
 }
 
-// Verify that \s matches non-breaking spaces
-// (IE fails on this test)
-if ( !rwhite.test( "\xA0" ) ) {
+// IE doesn't match non-breaking spaces with \s
+if ( rnotwhite.test( "\xA0" ) ) {
        trimLeft = /^[\s\xA0]+/;
        trimRight = /[\s\xA0]+$/;
 }