]> source.dussan.org Git - jquery.git/commitdiff
Made it so that you no longer need to build jQuery in order to run the test suite...
authorjeresig <jeresig@gmail.com>
Tue, 23 Mar 2010 16:12:16 +0000 (12:12 -0400)
committerwycats <wycats@gmail.com>
Sun, 20 Jun 2010 05:29:47 +0000 (22:29 -0700)
14 files changed:
src/ajax.js
src/attributes.js
src/core.js
src/css.js
src/data.js
src/effects.js
src/event.js
src/manipulation.js
src/outro.js
src/sizzle-jquery.js
src/support.js
src/traversing.js
test/index.html
test/unit/attributes.js

index f797e1a78698ef48eca2b15fd87de4c676bc8a54..7cf280ab33ab60f94f0bbbfc358ffde1cac25857 100644 (file)
@@ -1,4 +1,4 @@
-var jsc = now(),
+var jsc = jQuery.now(),
        rscript = /<script(.|\s)*?\/script>/gi,
        rselectTextarea = /select|textarea/i,
        rinput = /color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,
@@ -259,7 +259,7 @@ jQuery.extend({
                }
 
                if ( s.cache === false && type === "GET" ) {
-                       var ts = now();
+                       var ts = jQuery.now();
 
                        // try replacing _= if it is there
                        var ret = s.url.replace(rts, "$1_=" + ts + "$2");
index 4f7055a6e4f570cd388bbb461286ef34de6c86a3..aca9e055dbdf1e113ca5d798230fb103cd7130c2 100644 (file)
@@ -9,7 +9,7 @@ var rclass = /[\n\t]/g,
 
 jQuery.fn.extend({
        attr: function( name, value ) {
-               return access( this, name, value, true, jQuery.attr );
+               return jQuery.access( this, name, value, true, jQuery.attr );
        },
 
        removeAttr: function( name, fn ) {
index 699b87ac9422843848f784daff9012e5cb183395..e1a3a6df2523b0d335cbfcf1ebe114513efbc186 100644 (file)
@@ -1,3 +1,5 @@
+(function() {
+
 // Define a local copy of jQuery
 var jQuery = function( selector, context ) {
                // The jQuery object is actually just the init constructor 'enhanced'
@@ -11,7 +13,7 @@ var jQuery = function( selector, context ) {
        _$ = window.$,
 
        // Use the correct document accordingly with window argument (sandbox)
-       document = window.document,
+       //document = window.document,
 
        // A central reference to the root jQuery(document)
        rootjQuery,
@@ -699,6 +701,39 @@ jQuery.extend({
                return proxy;
        },
 
+       // Mutifunctional method to get and set values to a collection
+       // The value/s can be optionally by executed if its a function
+       access: function( elems, key, value, exec, fn, pass ) {
+               var length = elems.length;
+       
+               // Setting many attributes
+               if ( typeof key === "object" ) {
+                       for ( var k in key ) {
+                               jQuery.access( elems, k, key[k], exec, fn, value );
+                       }
+                       return elems;
+               }
+       
+               // Setting one attribute
+               if ( value !== undefined ) {
+                       // Optionally, function values get executed if exec is true
+                       exec = !pass && exec && jQuery.isFunction(value);
+               
+                       for ( var i = 0; i < length; i++ ) {
+                               fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
+                       }
+               
+                       return elems;
+               }
+       
+               // Getting an attribute
+               return length ? fn( elems[0], key ) : undefined;
+       },
+
+       now: function() {
+               return (new Date()).getTime();
+       },
+
        // Use of jQuery.browser is frowned upon.
        // More details: http://docs.jquery.com/Utilities/jQuery.browser
        uaMatch: function( ua ) {
@@ -779,51 +814,7 @@ function doScrollCheck() {
        jQuery.ready();
 }
 
-function evalScript( i, elem ) {
-       if ( elem.src ) {
-               jQuery.ajax({
-                       url: elem.src,
-                       async: false,
-                       dataType: "script"
-               });
-       } else {
-               jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
-       }
-
-       if ( elem.parentNode ) {
-               elem.parentNode.removeChild( elem );
-       }
-}
-
-// Mutifunctional method to get and set values to a collection
-// The value/s can be optionally by executed if its a function
-function access( elems, key, value, exec, fn, pass ) {
-       var length = elems.length;
-       
-       // Setting many attributes
-       if ( typeof key === "object" ) {
-               for ( var k in key ) {
-                       access( elems, k, key[k], exec, fn, value );
-               }
-               return elems;
-       }
-       
-       // Setting one attribute
-       if ( value !== undefined ) {
-               // Optionally, function values get executed if exec is true
-               exec = !pass && exec && jQuery.isFunction(value);
-               
-               for ( var i = 0; i < length; i++ ) {
-                       fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
-               }
-               
-               return elems;
-       }
-       
-       // Getting an attribute
-       return length ? fn( elems[0], key ) : undefined;
-}
+// Expose jQuery to the global object
+window.jQuery = window.$ = jQuery;
 
-function now() {
-       return (new Date()).getTime();
-}
+})();
index f675e13fc25a217faa7a9ddbe07e761b7cd360e5..ad0da6469919b513d891712b95aba1a8c65ba41c 100644 (file)
@@ -21,7 +21,7 @@ var rexclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
        };
 
 jQuery.fn.css = function( name, value ) {
-       return access( this, name, value, true, function( elem, name, value ) {
+       return jQuery.access( this, name, value, true, function( elem, name, value ) {
                if ( value === undefined ) {
                        return jQuery.curCSS( elem, name );
                }
index 109d55686cd261d136290287990f7c078b9f072a..cddd8bdead0042476124e1a61652651fa74c0a6a 100644 (file)
@@ -1,4 +1,4 @@
-var expando = "jQuery" + now(), uuid = 0, windowData = {};
+var expando = "jQuery" + jQuery.now(), uuid = 0, windowData = {};
 
 jQuery.extend({
        cache: {},
index 97456ccc4b4cab163ac00faecef36b43df9f5f85..40326e23da1b9a2a5f30b0bae31490bb82b2bfee 100644 (file)
@@ -320,7 +320,7 @@ jQuery.fx.prototype = {
 
        // Start an animation from one number to another
        custom: function( from, to, unit ) {
-               this.startTime = now();
+               this.startTime = jQuery.now();
                this.start = from;
                this.end = to;
                this.unit = unit || this.unit || "px";
@@ -366,7 +366,7 @@ jQuery.fx.prototype = {
 
        // Each step of an animation
        step: function( gotoEnd ) {
-               var t = now(), done = true;
+               var t = jQuery.now(), done = true;
 
                if ( gotoEnd || t >= this.options.duration + this.startTime ) {
                        this.now = this.end;
index 173bab10e3a7db04aac1473b9db1bce34e3bf398..588a7979ac5a5443b5834d667faad68b1ae88267 100644 (file)
@@ -554,7 +554,7 @@ jQuery.Event = function( src ) {
 
        // timeStamp is buggy for some events on Firefox(#3843)
        // So we won't rely on the native value
-       this.timeStamp = now();
+       this.timeStamp = jQuery.now();
 
        // Mark it as fixed
        this[ expando ] = true;
index be12aa12bc81eb0e279926d19e89929c4ca21bb7..cb898cc3ca109b16b60d48f63424cf1cff610d53 100644 (file)
@@ -584,3 +584,19 @@ jQuery.extend({
                }
        }
 });
+
+function evalScript( i, elem ) {
+       if ( elem.src ) {
+               jQuery.ajax({
+                       url: elem.src,
+                       async: false,
+                       dataType: "script"
+               });
+       } else {
+               jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
+       }
+
+       if ( elem.parentNode ) {
+               elem.parentNode.removeChild( elem );
+       }
+}
\ No newline at end of file
index 5d87b7e7b16dc9fcedb2e4792488456eeb659495..7773a74fdc1e816f1b54fd011a5d6ac454e05dd6 100644 (file)
@@ -1,4 +1 @@
-// Expose jQuery to the global object
-window.jQuery = window.$ = jQuery;
-
 })(window);
index 99f4d291b2be791ecbbb8a7510b1ad714bb604cc..f15b08252c1c47a5143892bdb3f00d7bb40ac3a2 100644 (file)
@@ -2,6 +2,6 @@ jQuery.find = Sizzle;
 jQuery.expr = Sizzle.selectors;
 jQuery.expr[":"] = jQuery.expr.filters;
 jQuery.unique = Sizzle.uniqueSort;
-jQuery.text = getText;
-jQuery.isXMLDoc = isXML;
-jQuery.contains = contains;
+jQuery.text = Sizzle.getText;
+jQuery.isXMLDoc = Sizzle.isXML;
+jQuery.contains = Sizzle.contains;
index befc5327288da046cf5d209baeee1e03625c6780..cddd3dc3b962af886a59cf9d3c6468bfe66b787d 100644 (file)
@@ -5,7 +5,7 @@
        var root = document.documentElement,
                script = document.createElement("script"),
                div = document.createElement("div"),
-               id = "script" + now();
+               id = "script" + jQuery.now();
 
        div.style.display = "none";
        div.innerHTML = "   <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
index 67760450f300d60c876f556615ff73151a89ff4a..d485d691a66297c289222b498eba4337b212c021 100644 (file)
@@ -1,37 +1,9 @@
 var runtil = /Until$/,
        rparentsprev = /^(?:parents|prevUntil|prevAll)/,
        // Note: This RegExp should be improved, or likely pulled from Sizzle
-       rmultiselector = /,/;
-
-// Implement the identical functionality for filter and not
-var winnow = function( elements, qualifier, keep ) {
-       if ( jQuery.isFunction( qualifier ) ) {
-               return jQuery.grep(elements, function( elem, i ) {
-                       var retVal = !!qualifier.call( elem, i, elem );
-                       return retVal === keep;
-               });
-
-       } else if ( qualifier.nodeType ) {
-               return jQuery.grep(elements, function( elem, i ) {
-                       return (elem === qualifier) === keep;
-               });
-
-       } else if ( typeof qualifier === "string" ) {
-               var filtered = jQuery.grep(elements, function( elem ) {
-                       return elem.nodeType === 1;
-               });
-
-               if ( isSimple.test( qualifier ) ) {
-                       return jQuery.filter(qualifier, filtered, !keep);
-               } else {
-                       qualifier = jQuery.filter( qualifier, filtered );
-               }
-       }
-
-       return jQuery.grep(elements, function( elem, i ) {
-               return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
-       });
-};
+       rmultiselector = /,/,
+       isSimple = /^.[^:#\[\.,]*$/,
+       slice = Array.prototype.slice;
 
 jQuery.fn.extend({
        find: function( selector ) {
@@ -269,3 +241,33 @@ jQuery.extend({
                return r;
        }
 });
+
+// Implement the identical functionality for filter and not
+function winnow( elements, qualifier, keep ) {
+       if ( jQuery.isFunction( qualifier ) ) {
+               return jQuery.grep(elements, function( elem, i ) {
+                       var retVal = !!qualifier.call( elem, i, elem );
+                       return retVal === keep;
+               });
+
+       } else if ( qualifier.nodeType ) {
+               return jQuery.grep(elements, function( elem, i ) {
+                       return (elem === qualifier) === keep;
+               });
+
+       } else if ( typeof qualifier === "string" ) {
+               var filtered = jQuery.grep(elements, function( elem ) {
+                       return elem.nodeType === 1;
+               });
+
+               if ( isSimple.test( qualifier ) ) {
+                       return jQuery.filter(qualifier, filtered, !keep);
+               } else {
+                       qualifier = jQuery.filter( qualifier, filtered );
+               }
+       }
+
+       return jQuery.grep(elements, function( elem, i ) {
+               return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
+       });
+};
\ No newline at end of file
index d6d02f47f070eaab1010426b28d7ee6286de05a7..13abd97f9f3c9840a799c4c914e9f51bb9de74b9 100644 (file)
@@ -6,23 +6,39 @@
        <link rel="Stylesheet" media="screen" href="qunit/qunit/qunit.css" />
        <link rel="Stylesheet" media="screen" href="data/testsuite.css" />
        <!-- Includes -->
-       <script type="text/javascript" src="data/testinit.js"></script>
-       <script type="text/javascript" src="../dist/jquery.js"></script>
-       <script type="text/javascript" src="qunit/qunit/qunit.js"></script>
-       <script type="text/javascript" src="data/testrunner.js"></script>
-       <script type="text/javascript" src="unit/core.js"></script>
-       <script type="text/javascript" src="unit/data.js"></script>
-       <script type="text/javascript" src="unit/queue.js"></script>
-       <script type="text/javascript" src="unit/attributes.js"></script>
-       <script type="text/javascript" src="unit/css.js"></script>
-       <script type="text/javascript" src="unit/traversing.js"></script>
-       <script type="text/javascript" src="unit/manipulation.js"></script>
-       <script type="text/javascript" src="unit/dimensions.js"></script>
-       <script type="text/javascript" src="unit/selector.js"></script>
-       <script type="text/javascript" src="unit/event.js"></script>
-       <script type="text/javascript" src="unit/ajax.js"></script>
-       <script type="text/javascript" src="unit/effects.js"></script>
-       <script type="text/javascript" src="unit/offset.js"></script>
+       <script src="data/testinit.js"></script>
+
+       <script src="../src/core.js"></script>
+       <script src="../src/support.js"></script>
+       <script src="../src/sizzle/sizzle.js"></script>
+       <script src="../src/sizzle-jquery.js"></script>
+       <script src="../src/data.js"></script>
+       <script src="../src/queue.js"></script>
+       <script src="../src/attributes.js"></script>
+       <script src="../src/css.js"></script>
+       <script src="../src/traversing.js"></script>
+       <script src="../src/manipulation.js"></script>
+       <script src="../src/dimensions.js"></script>
+       <script src="../src/event.js"></script>
+       <script src="../src/ajax.js"></script>
+       <script src="../src/effects.js"></script>
+       <script src="../src/offset.js"></script>
+
+       <script src="qunit/qunit/qunit.js"></script>
+       <script src="data/testrunner.js"></script>
+       <script src="unit/core.js"></script>
+       <script src="unit/data.js"></script>
+       <script src="unit/queue.js"></script>
+       <script src="unit/attributes.js"></script>
+       <script src="unit/css.js"></script>
+       <script src="unit/traversing.js"></script>
+       <script src="unit/manipulation.js"></script>
+       <script src="unit/dimensions.js"></script>
+       <script src="unit/selector.js"></script>
+       <script src="unit/event.js"></script>
+       <script src="unit/ajax.js"></script>
+       <script src="unit/effects.js"></script>
+       <script src="unit/offset.js"></script>
 </head>
 
 <body id="body">
index d7abbad359b8c524566f5eeb55f306be1b4b1032..21d3d94bcb96a23cc5ad952820537223ad89fdfc 100644 (file)
@@ -482,8 +482,10 @@ test("addClass(Function) with incoming value", function() {
        });
 
        div.addClass(function(i, val) {
-               equals( val, old[i], "Make sure the incoming value is correct." );
-               return "test";
+               if ( this.id !== "_firebugConsole" ) {
+                       equals( val, old[i], "Make sure the incoming value is correct." );
+                       return "test";
+               }
        });
 
        var pass = true;
@@ -553,8 +555,10 @@ test("removeClass(Function) with incoming value", function() {
        });
 
        $divs.removeClass(function(i, val) {
-               equals( val, old[i], "Make sure the incoming value is correct." );
-               return "test";
+               if ( this.id !== "_firebugConsole" ) {
+                       equals( val, old[i], "Make sure the incoming value is correct." );
+                       return "test";
+               }
        });
 
        ok( !$divs.is('.test'), "Remove Class" );