Refactored test suite: All tests are now compiled into one file, runs much faster...
[jquery.git] / src / jquery / jquery.js
index c025c81..11cd56e 100644 (file)
@@ -28,7 +28,7 @@ window.undefined = window.undefined;
  * @name jQuery
  * @cat Core
  */
-function jQuery(a,c) {
+jQuery = function(a,c) {
 
        // Shortcut for document ready (because $(document).each() is silly)
        if ( a && a.constructor == Function && jQuery.fn.ready )
@@ -67,7 +67,7 @@ function jQuery(a,c) {
        // If so, execute it in context
        if ( fn && fn.constructor == Function )
                this.each(fn);
-}
+};
 
 // Map over the $ in case of overwrite
 if ( typeof $ != "undefined" )
@@ -127,9 +127,8 @@ if ( typeof $ != "undefined" )
  * @before <p>one</p> <div><p>two</p></div> <p>three</p>
  * @result [ <p>two</p> ]
  *
- * @example $(document).ready( loaded );
- * @desc Executes the "loaded" function when the DOM is ready to
- * be manipulated.
+ * @example $(document.body).background( "black" );
+ * @desc Sets the background color of the page to black.
  *
  * @name $
  * @param Element elem A DOM element to be encapsulated by a jQuery object.
@@ -151,10 +150,15 @@ if ( typeof $ != "undefined" )
 
 /**
  * A shorthand for $(document).ready(), allowing you to bind a function
- * to be executed when the DOM document has finished loading.
+ * to be executed when the DOM document has finished loading. This function
+ * behaves just like $(document).ready(), in that it should be used to wrap
+ * all of the other $() operations on your page. While this function is,
+ * technically, chainable - there really isn't much use for chaining against it.
  *
- * @example $( loaded )
- * @desc Executes the function "loaded" when the DOM is ready to be used.
+ * @example $(function(){
+ *   // Document is ready
+ * });
+ * @desc Executes the function when the DOM is ready to be used.
  *
  * @name $
  * @param Function fn The function to execute when the DOM is ready.
@@ -163,11 +167,13 @@ if ( typeof $ != "undefined" )
  */
 
 /**
- * A means of creating a duplicate copy of a jQuery object.
+ * A means of creating a cloned copy of a jQuery object. This function
+ * copies the set of matched elements from one jQuery object and creates
+ * another, new, jQuery object containing the same elements.
  *
  * @example var div = $("div");
- * $( div ).find("p")
- * @desc Locates all p elements with all div elements, without disrupting the original jQuery object contained in 'div'.
+ * $( div ).find("p");
+ * @desc Locates all p elements with all div elements, without disrupting the original jQuery object contained in 'div' (as would normally be the case if a simple div.find("p") was done).
  *
  * @name $
  * @param jQuery obj The jQuery object to be cloned.
@@ -197,7 +203,7 @@ jQuery.fn = jQuery.prototype = {
         * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
         * @result 2
         *
-        * @test cmpOK( $("div").length, "==", 2, "Get Number of Elements Found" );
+        * @test ok( $("div").length == 2, "Get Number of Elements Found" );
         *
         * @property
         * @name length
@@ -212,7 +218,7 @@ jQuery.fn = jQuery.prototype = {
         * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
         * @result 2
         *
-        * @test cmpOK( $("div").size(), "==", 2, "Get Number of Elements Found" );
+        * @test ok( $("div").size() == 2, "Get Number of Elements Found" );
         *
         * @name size
         * @type Number
@@ -246,7 +252,7 @@ jQuery.fn = jQuery.prototype = {
         * @before <img src="test1.jpg"/> <img src="test2.jpg"/>
         * @result [ <img src="test1.jpg"/> ]
         *
-        * @test cmpOK( $("div").get(0), "==", document.getElementById("main"), "Get A Single Element" );
+        * @test ok( $("div").get(0) == document.getElementById("main"), "Get A Single Element" );
         *
         * @name get
         * @type Element
@@ -325,6 +331,38 @@ jQuery.fn = jQuery.prototype = {
                return jQuery.each( this, fn, args );
        },
 
+       /**
+        * Searches every matched element for the object and returns
+        * the index of the element, if found, starting with zero. 
+        * Returns -1 if the object wasn't found.
+        *
+        * @example $("*").index(document.getElementById('foobar')) 
+        * @before <div id="foobar"></div><b></b><span id="foo"></span>
+        * @result 0
+        *
+        * @example $("*").index(document.getElementById('foo')) 
+        * @before <div id="foobar"></div><b></b><span id="foo"></span>
+        * @result 2
+        *
+        * @example $("*").index(document.getElementById('bar')) 
+        * @before <div id="foobar"></div><b></b><span id="foo"></span>
+        * @result -1
+        *
+        * @test ok( $([window, document]).index(window) == 0, "Check for index of elements" );
+        * @test ok( $([window, document]).index(document) == 1, "Check for index of elements" );
+        * @test var inputElements = $('#radio1,#radio2,#check1,#check2');
+        * @test ok( inputElements.index(document.getElementById('radio1')) == 0, "Check for index of elements" );
+        * @test ok( inputElements.index(document.getElementById('radio2')) == 1, "Check for index of elements" );
+        * @test ok( inputElements.index(document.getElementById('check1')) == 2, "Check for index of elements" );
+        * @test ok( inputElements.index(document.getElementById('check2')) == 3, "Check for index of elements" );
+        * @test ok( inputElements.index(window) == -1, "Check for not found index" );
+        * @test ok( inputElements.index(document) == -1, "Check for not found index" );
+        * 
+        * @name index
+        * @type Number
+        * @param Object obj Object to search for
+        * @cat Core
+        */
        index: function( obj ) {
                var pos = -1;
                this.each(function(i){
@@ -342,6 +380,19 @@ jQuery.fn = jQuery.prototype = {
         * @before <img src="test.jpg"/>
         * @result test.jpg
         *
+        * @test ok( $('#text1').attr('value') == "Test", 'Check for value attribute' );
+        * @test ok( $('#text1').attr('type') == "text", 'Check for type attribute' );
+        * @test ok( $('#radio1').attr('type') == "radio", 'Check for type attribute' );
+        * @test ok( $('#check1').attr('type') == "checkbox", 'Check for type attribute' );
+        * @test ok( $('#simon1').attr('rel') == "bookmark", 'Check for rel attribute' );
+        * @test ok( $('#google').attr('title') == "Google!", 'Check for title attribute' );
+        * @test ok( $('#mark').attr('hreflang') == "en", 'Check for hreflang attribute' );
+        * @test ok( $('#en').attr('lang') == "en", 'Check for lang attribute' );
+        * @test ok( $('#simon').attr('class') == "blog link", 'Check for class attribute' );
+        * @test ok( $('#name').attr('name') == "name", 'Check for name attribute' );
+        * @test ok( $('#text1').attr('name') == "action", 'Check for name attribute' );
+        * @test ok( $('#form').attr('action') == "formaction", 'Check for action attribute' );
+        * 
         * @name attr
         * @type Object
         * @param String name The name of the property to access.
@@ -384,6 +435,13 @@ jQuery.fn = jQuery.prototype = {
         * }
         * ok( pass, "Set Attribute" );
         *
+        * @test $("#name").attr('name', 'something');
+        * ok( $("#name").name() == 'something', 'Set name attribute' );
+        * @test $("#check2").attr('checked', true);
+        * ok( document.getElementById('check2').checked == true, 'Set checked attribute' );
+        * $("#check2").attr('checked', false);
+        * ok( document.getElementById('check2').checked == false, 'Set checked attribute' );
+        *
         * @name attr
         * @type jQuery
         * @param String key The name of the property to set.
@@ -423,6 +481,19 @@ jQuery.fn = jQuery.prototype = {
         * @example $("p").css("color");
         * @before <p style="color:red;">Test Paragraph.</p>
         * @result red
+        * @desc Retrieves the color style of the first paragraph
+        *
+        * @example $("p").css("fontWeight");
+        * @before <p style="font-weight: bold;">Test Paragraph.</p>
+        * @result bold
+        * @desc Retrieves the font-weight style of the first paragraph.
+        * Note that for all style properties with a dash (like 'font-weight'), you have to
+        * write it in camelCase. In other words: Every time you have a '-' in a 
+        * property, remove it and replace the next character with an uppercase 
+        * representation of itself. Eg. fontWeight, fontSize, fontFamily, borderWidth,
+        * borderStyle, borderBottomWidth etc.
+        *
+        * @test ok( $('#foo').css("display") == 'block', 'Check for css property "display"');
         *
         * @name css
         * @type Object
@@ -439,6 +510,12 @@ jQuery.fn = jQuery.prototype = {
         * @before <p>Test Paragraph.</p>
         * @result <p style="color:red; background:blue;">Test Paragraph.</p>
         *
+        * @test ok( $('#foo').is(':visible'), 'Modifying CSS display: Assert element is visible');
+        * @test $('#foo').css({display: 'none'});
+        * ok( !$('#foo').is(':visible'), 'Modified CSS display: Assert element is hidden');
+        * @test $('#foo').css({display: 'block'});
+        * ok( $('#foo').is(':visible'), 'Modified CSS display: Assert element is visible');
+        * 
         * @name css
         * @type jQuery
         * @param Hash prop A set of key/value pairs to set as style properties.
@@ -451,6 +528,14 @@ jQuery.fn = jQuery.prototype = {
         * @example $("p").css("color","red");
         * @before <p>Test Paragraph.</p>
         * @result <p style="color:red;">Test Paragraph.</p>
+        * @desc Changes the color of all paragraphs to red
+        *
+        *
+        * @test ok( $('#foo').is(':visible'), 'Modifying CSS display: Assert element is visible');
+        * @test $('#foo').css('display', 'none');
+        * ok( !$('#foo').is(':visible'), 'Modified CSS display: Assert element is hidden');
+        * @test $('#foo').css('display', 'block');
+        * ok( $('#foo').is(':visible'), 'Modified CSS display: Assert element is visible');
         *
         * @name css
         * @type jQuery
@@ -471,6 +556,9 @@ jQuery.fn = jQuery.prototype = {
         * @before <p>Test Paragraph.</p>
         * @result Test Paragraph.
         *
+        * @test var expected = "This link has class=\"blog\": Simon Willison's Weblog";
+        * ok( $('#sap').text() == expected, 'Check for merged text of more then one element.' );
+        *
         * @name text
         * @type String
         * @cat DOM
@@ -502,6 +590,16 @@ jQuery.fn = jQuery.prototype = {
         * @example $("p").wrap("<div class='wrap'></div>");
         * @before <p>Test Paragraph.</p>
         * @result <div class='wrap'><p>Test Paragraph.</p></div>
+        * 
+        * @test var defaultText = 'Try them out:'
+        * var result = $('#first').wrap('<div class="red"><span></span></div>').text();
+        * ok( defaultText == result, 'Check for simple wrapping' );
+        * ok( $('#first').parent().parent().is('.red'), 'Check if wrapper div has class "red"' );
+        *
+        * @test var defaultText = 'Try them out:'
+        * var result = $('#first').wrap('<div class="red">xx<span></span>yy</div>').text()
+        * ok( 'xx' + defaultText + 'yy' == result, 'Check for wrapping' );
+        * ok( $('#first').parent().parent().is('.red'), 'Check if wrapper div has class "red"' );
         *
         * @name wrap
         * @type jQuery
@@ -559,6 +657,10 @@ jQuery.fn = jQuery.prototype = {
         * @before <p>I would like to say: </p>
         * @result <p>I would like to say: <b>Hello</b></p>
         *
+        * @test var defaultText = 'Try them out:'
+        * var result = $('#first').append('<b>buga</b>');
+        * ok( result.text() == defaultText + 'buga', 'Check if text appending works' );
+        *
         * @name append
         * @type jQuery
         * @param String html A string of HTML, that will be created on the fly and appended to the target.
@@ -574,6 +676,10 @@ jQuery.fn = jQuery.prototype = {
         * @before <p>I would like to say: </p><b id="foo">Hello</b>
         * @result <p>I would like to say: <b id="foo">Hello</b></p>
         *
+        * @test var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";
+        * $('#sap').append(document.getElementById('first'));
+        * ok( expected == $('#sap').text(), "Check for appending of element" );
+        *
         * @name append
         * @type jQuery
         * @param Element elem A DOM element that will be appended.
@@ -589,6 +695,10 @@ jQuery.fn = jQuery.prototype = {
         * @before <p>I would like to say: </p><b>Hello</b>
         * @result <p>I would like to say: <b>Hello</b></p>
         *
+        * @test var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
+        * $('#sap').append([document.getElementById('first'), document.getElementById('yahoo')]);
+        * ok( expected == $('#sap').text(), "Check for appending of array of elements" );
+        *
         * @name append
         * @type jQuery
         * @param Array<Element> elems An array of elements, all of which will be appended.
@@ -610,6 +720,10 @@ jQuery.fn = jQuery.prototype = {
         * @before <p>I would like to say: </p>
         * @result <p><b>Hello</b>I would like to say: </p>
         *
+        * @test var defaultText = 'Try them out:'
+        * var result = $('#first').prepend('<b>buga</b>');
+        * ok( result.text() == 'buga' + defaultText, 'Check if text prepending works' );
+        *
         * @name prepend
         * @type jQuery
         * @param String html A string of HTML, that will be created on the fly and appended to the target.
@@ -617,13 +731,17 @@ jQuery.fn = jQuery.prototype = {
         */
 
        /**
-        * Append an element to the inside of all matched elements.
+        * Prepend an element to the inside of all matched elements.
         * This operation is the best way to insert an element inside, at the
         * beginning, of all the matched element.
         *
         * @example $("p").prepend( $("#foo")[0] );
         * @before <p>I would like to say: </p><b id="foo">Hello</b>
         * @result <p><b id="foo">Hello</b>I would like to say: </p>
+        *       
+        * @test var expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
+        * $('#sap').prepend(document.getElementById('first'));
+        * ok( expected == $('#sap').text(), "Check for prepending of element" );
         *
         * @name prepend
         * @type jQuery
@@ -632,7 +750,7 @@ jQuery.fn = jQuery.prototype = {
         */
 
        /**
-        * Append any number of elements to the inside of all matched elements.
+        * Prepend any number of elements to the inside of all matched elements.
         * This operation is the best way to insert a set of elements inside, at the
         * beginning, of all the matched element.
         *
@@ -640,6 +758,10 @@ jQuery.fn = jQuery.prototype = {
         * @before <p>I would like to say: </p><b>Hello</b>
         * @result <p><b>Hello</b>I would like to say: </p>
         *
+        * @test var expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
+        * $('#sap').prepend([document.getElementById('first'), document.getElementById('yahoo')]);
+        * ok( expected == $('#sap').text(), "Check for prepending of array of elements" );
+        *
         * @name prepend
         * @type jQuery
         * @param Array<Element> elems An array of elements, all of which will be appended.
@@ -659,6 +781,10 @@ jQuery.fn = jQuery.prototype = {
         * @before <p>I would like to say: </p>
         * @result <b>Hello</b><p>I would like to say: </p>
         *
+        * @test var expected = 'This is a normal link: bugaYahoo';
+        * $('#yahoo').before('<b>buga</b>');
+        * ok( expected == $('#en').text(), 'Insert String before' );
+        *
         * @name before
         * @type jQuery
         * @param String html A string of HTML, that will be created on the fly and appended to the target.
@@ -672,6 +798,10 @@ jQuery.fn = jQuery.prototype = {
         * @before <p>I would like to say: </p><b id="foo">Hello</b>
         * @result <b id="foo">Hello</b><p>I would like to say: </p>
         *
+        * @test var expected = "This is a normal link: Try them out:Yahoo";
+        * $('#yahoo').before(document.getElementById('first'));
+        * ok( expected == $('#en').text(), "Insert element before" );
+        *
         * @name before
         * @type jQuery
         * @param Element elem A DOM element that will be appended.
@@ -685,6 +815,10 @@ jQuery.fn = jQuery.prototype = {
         * @before <p>I would like to say: </p><b>Hello</b>
         * @result <b>Hello</b><p>I would like to say: </p>
         *
+        * @test var expected = "This is a normal link: Try them out:diveintomarkYahoo";
+        * $('#yahoo').before([document.getElementById('first'), document.getElementById('mark')]);
+        * ok( expected == $('#en').text(), "Insert array of elements before" );
+        *
         * @name before
         * @type jQuery
         * @param Array<Element> elems An array of elements, all of which will be appended.
@@ -704,6 +838,10 @@ jQuery.fn = jQuery.prototype = {
         * @before <p>I would like to say: </p>
         * @result <p>I would like to say: </p><b>Hello</b>
         *
+        * @test var expected = 'This is a normal link: Yahoobuga';
+        * $('#yahoo').after('<b>buga</b>');
+        * ok( expected == $('#en').text(), 'Insert String after' );
+        *
         * @name after
         * @type jQuery
         * @param String html A string of HTML, that will be created on the fly and appended to the target.
@@ -717,6 +855,10 @@ jQuery.fn = jQuery.prototype = {
         * @before <b id="foo">Hello</b><p>I would like to say: </p>
         * @result <p>I would like to say: </p><b id="foo">Hello</b>
         *
+        * @test var expected = "This is a normal link: YahooTry them out:";
+        * $('#yahoo').after(document.getElementById('first'));
+        * ok( expected == $('#en').text(), "Insert element after" );
+        *
         * @name after
         * @type jQuery
         * @param Element elem A DOM element that will be appended.
@@ -730,6 +872,10 @@ jQuery.fn = jQuery.prototype = {
         * @before <b>Hello</b><p>I would like to say: </p>
         * @result <p>I would like to say: </p><b>Hello</b>
         *
+        * @test var expected = "This is a normal link: YahooTry them out:diveintomark";
+        * $('#yahoo').after([document.getElementById('first'), document.getElementById('mark')]);
+        * ok( expected == $('#en').text(), "Insert array of elements after" );
+        *
         * @name after
         * @type jQuery
         * @param Array<Element> elems An array of elements, all of which will be appended.
@@ -750,6 +896,8 @@ jQuery.fn = jQuery.prototype = {
         * @before <p><span>Hello</span>, how are you?</p>
         * @result $("p").find("span").end() == [ <p>...</p> ]
         *
+        * @test ok( 'Yahoo' == $('#yahoo').parent().end().text(), 'Check for end' );
+        *
         * @name end
         * @type jQuery
         * @cat DOM/Traversing
@@ -770,6 +918,8 @@ jQuery.fn = jQuery.prototype = {
         * @before <p><span>Hello</span>, how are you?</p>
         * @result $("p").find("span") == [ <span>Hello</span> ]
         *
+        * @test ok( 'Yahoo' == $('#foo').find('.blogTest').text(), 'Check for find' );
+        *
         * @name find
         * @type jQuery
         * @param String expr An expression to search with.
@@ -792,6 +942,11 @@ jQuery.fn = jQuery.prototype = {
         * @before <b>Hello</b><p>, how are you?</p>
         * @result <b>Hello</b><p><b>Hello</b>, how are you?</p>
         *
+        * @test ok( 'This is a normal link: Yahoo' == $('#en').text(), 'Assert text for #en' );
+        * var clone = $('#yahoo').clone();
+        * ok( 'Try them out:Yahoo' == $('#first').append(clone).text(), 'Check for clone' );
+        * ok( 'This is a normal link: Yahoo' == $('#en').text(), 'Reassert text for #en' );
+        *
         * @name clone
         * @type jQuery
         * @cat DOM/Manipulation
@@ -814,6 +969,8 @@ jQuery.fn = jQuery.prototype = {
         * @before <p class="selected">Hello</p><p>How are you?</p>
         * @result $("p").filter(".selected") == [ <p class="selected">Hello</p> ]
         *
+        * @test isSet( $("input").filter(":checked").get(), q("radio2", "check1"), "Filter elements" );
+        *
         * @name filter
         * @type jQuery
         * @param String expr An expression to search with.
@@ -878,7 +1035,7 @@ jQuery.fn = jQuery.prototype = {
         * @example $("p").not("#selected")
         * @before <p>Hello</p><p id="selected">Hello Again</p>
         * @result [ <p>Hello</p> ]
-        * @test cmpOK($("#main > p#ap > a").not("#google").length, "==", 2, ".not")
+        * @test ok($("#main > p#ap > a").not("#google").length == 2, ".not")
         *
         * @name not
         * @type jQuery
@@ -938,17 +1095,55 @@ jQuery.fn = jQuery.prototype = {
        },
 
        /**
-        * A wrapper function for each() to be used by append and prepend.
-        * Handles cases where you're trying to modify the inner contents of
-        * a table, when you actually need to work with the tbody.
-        *
-        * @member jQuery
-        * @param {String} expr The expression with which to filter
+        * Checks the current selection against an expression and returns true,
+        * if the selection fits the given expression. Does return false, if the
+        * selection does not fit or the expression is not valid.
+        *
+        * @example $("input[@type='checkbox']").parent().is("form")
+        * @before <form><input type="checkbox" /></form>
+        * @result true
+        * @desc Returns true, because the parent of the input is a form element
+        * 
+        * @example $("input[@type='checkbox']").parent().is("form")
+        * @before <form><p><input type="checkbox" /></p></form>
+        * @result false
+        * @desc Returns false, because the parent of the input is a p element
+        *
+        * @example $("form").is(null)
+        * @before <form></form>
+        * @result false
+        * @desc An invalid expression always returns false.
+        *
+        * @test ok( $('#form').is('form'), 'Check for element: A form must be a form' );
+        * @test ok( !$('#form').is('div'), 'Check for element: A form is not a div' );
+        * @test ok( $('#mark').is('.blog'), 'Check for class: Expected class "blog"' );
+        * @test ok( !$('#mark').is('.link'), 'Check for class: Did not expect class "link"' );
+        * @test ok( $('#simon').is('.blog.link'), 'Check for multiple classes: Expected classes "blog" and "link"' );
+        * @test ok( !$('#simon').is('.blogTest'), 'Check for multiple classes: Expected classes "blog" and "link", but not "blogTest"' );
+        * @test ok( $('#en').is('[@lang="en"]'), 'Check for attribute: Expected attribute lang to be "en"' );
+        * @test ok( !$('#en').is('[@lang="de"]'), 'Check for attribute: Expected attribute lang to be "en", not "de"' );
+        * @test ok( $('#text1').is('[@type="text"]'), 'Check for attribute: Expected attribute type to be "text"' );
+        * @test ok( !$('#text1').is('[@type="radio"]'), 'Check for attribute: Expected attribute type to be "text", not "radio"' );
+        * @test ok( $('#text2').is(':disabled'), 'Check for pseudoclass: Expected to be disabled' );
+        * @test ok( !$('#text1').is(':disabled'), 'Check for pseudoclass: Expected not disabled' );
+        * @test ok( $('#radio2').is(':checked'), 'Check for pseudoclass: Expected to be checked' );
+        * @test ok( !$('#radio1').is(':checked'), 'Check for pseudoclass: Expected not checked' );
+        * @test ok( $('#foo').is('[p]'), 'Check for child: Expected a child "p" element' );
+        * @test ok( !$('#foo').is('[ul]'), 'Check for child: Did not expect "ul" element' );
+        * @test ok( $('#foo').is('[p][a][code]'), 'Check for childs: Expected "p", "a" and "code" child elements' );
+        * @test ok( !$('#foo').is('[p][a][code][ol]'), 'Check for childs: Expected "p", "a" and "code" child elements, but no "ol"' );
+        * @test ok( !$('#foo').is(0), 'Expected false for an invalid expression - 0' );
+        * @test ok( !$('#foo').is(null), 'Expected false for an invalid expression - null' );
+        * @test ok( !$('#foo').is(''), 'Expected false for an invalid expression - ""' );
+        * @test ok( !$('#foo').is(undefined), 'Expected false for an invalid expression - undefined' );
+        *
+        * @name is
         * @type Boolean
+        * @param String expr The expression with which to filter
         * @cat DOM/Traversing
         */
        is: function(expr) {
-               return expr ? jQuery.filter(expr,this).r.length > 0 : this.length > 0;
+               return expr ? jQuery.filter(expr,this).r.length > 0 : false;
        },
 
        /**
@@ -1029,6 +1224,19 @@ jQuery.fn = jQuery.prototype = {
 /**
  * Extend one object with another, returning the original,
  * modified, object. This is a great utility for simple inheritance.
+ * 
+ * @example var settings = { validate: false, limit: 5, name: "foo" };
+ * var options = { validate: true, name: "bar" };
+ * jQuery.extend(settings, options);
+ * @result settings == { validate: true, limit: 5, name: "bar" }
+ *
+ * @test var settings = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" };
+ * var options =     { xnumber2: 1, xstring2: "x", xxx: "newstring" };
+ * var optionsCopy = { xnumber2: 1, xstring2: "x", xxx: "newstring" };
+ * var merged = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "x", xxx: "newstring" };
+ * jQuery.extend(settings, options);
+ * isSet( settings, merged, "Check if extended: settings must be extended" );
+ * isSet ( options, optionsCopy, "Check if not modified: options must not be modified" );
  *
  * @name $.extend
  * @param Object obj The object to extend
@@ -1104,11 +1312,23 @@ jQuery.extend({
 
        /**
         * A generic iterator function, which can be used to seemlessly
-        * iterate over both objects and arrays.
+        * iterate over both objects and arrays. This function is not the same
+        * as $().each() - which is used to iterate, exclusively, over a jQuery
+        * object. This function can be used to iterate over anything.
+        *
+        * @example $.each( [0,1,2], function(i){
+        *   alert( "Item #" + i + ": " + this );
+        * });
+        * @desc This is an example of iterating over the items in an array, accessing both the current item and its index.
+        *
+        * @example $.each( { name: "John", lang: "JS" }, function(i){
+        *   alert( "Name: " + i + ", Value: " + this );
+        * });
+        * @desc This is an example of iterating over the properties in an Object, accessing both the current item and its key.
         *
         * @name $.each
         * @param Object obj The object, or array, to iterate over.
-        * @param Object fn The function that will be executed on every object.
+        * @param Function fn The function that will be executed on every object.
         * @type Object
         * @cat Javascript
         */
@@ -1329,7 +1549,7 @@ jQuery.extend({
         * @test t( "Element Selector", "div", ["main","foo"] );
         * @test t( "Element Selector", "body", ["body"] );
         * @test t( "Element Selector", "html", ["html"] );
-        * @test cmpOK( $("*").size(), ">=", 30, "Element Selector" );
+        * @test ok( $("*").size() >= 30, "Element Selector" );
         * @test t( "Parent Element", "div div", ["foo"] );
         *
         * @test t( "ID Selector", "#body", ["body"] );
@@ -1377,15 +1597,16 @@ jQuery.extend({
         * @test t( "Last Child", "p:last-child", ["sap"] );
         * @test t( "Only Child", "a:only-child", ["simon1","anchor1","yahoo","anchor2"] );
         * @test t( "Empty", "ul:empty", ["firstUL"] );
-        * @test t( "Enabled UI Element", "input:enabled", ["text1","radio1","radio2","check1","check2","hidden1","hidden2"] );
+        * @test t( "Enabled UI Element", "input:enabled", ["text1","radio1","radio2","check1","check2","hidden1","hidden2","name"] );
         * @test t( "Disabled UI Element", "input:disabled", ["text2"] );
         * @test t( "Checked UI Element", "input:checked", ["radio2","check1"] );
+        * @test t( "Selected Option Element", "option:selected", ["option1a","option2d","option3b","option3c"] );
         * @test t( "Text Contains", "a:contains('Google')", ["google","groups"] );
         * @test t( "Text Contains", "a:contains('Google Groups')", ["groups"] );
         * @test t( "Element Preceded By", "p ~ div", ["foo"] );
         * @test t( "Not", "a.blog:not(.link)", ["mark"] );
         *
-        * @test cmpOK( jQuery.find("//*").length, ">=", 30, "All Elements (//*)" );
+        * @test ok( jQuery.find("//*").length >= 30, "All Elements (//*)" );
         * @test t( "All Div Elements", "//div", ["main","foo"] );
         * @test t( "Absolute Path", "/html/body", ["body"] );
         * @test t( "Absolute Path w/ *", "/* /body", ["body"] );
@@ -1409,9 +1630,14 @@ jQuery.extend({
         * @test t( "Position Greater Than", "p:gt(0)", ["ap","sndp","en","sap","first"] );
         * @test t( "Position Less Than", "p:lt(3)", ["firstp","ap","sndp"] );
         * @test t( "Is A Parent", "p:parent", ["firstp","ap","sndp","en","sap","first"] );
-        * @test t( "Is Visible", "input:visible", ["text1","text2","radio1","radio2","check1","check2"] );
+        * @test t( "Is Visible", "input:visible", ["text1","text2","radio1","radio2","check1","check2","name"] );
         * @test t( "Is Hidden", "input:hidden", ["hidden1","hidden2"] );
         *
+        * @test t( "Grouped Form Elements", "input[@name='foo[bar]']", ["hidden2"] );
+        *
+        * @test t( "All Children of ID", "#foo/*", ["sndp", "en", "sap"]  );
+        * @test t( "All Children of ID with no children", "#firstUL/*", []  );
+        *
         * @name $.find
         * @type Array<Element>
         * @private
@@ -1531,7 +1757,7 @@ jQuery.extend({
                if ( fix[name] ) {
                        if ( value != undefined ) elem[fix[name]] = value;
                        return elem[fix[name]];
-               } else if ( elem.getAttribute ) {
+               } else if ( elem.getAttribute != undefined ) {
                        if ( value != undefined ) elem.setAttribute( name, value );
                        return elem.getAttribute( name, 2 );
                } else {
@@ -1544,16 +1770,16 @@ jQuery.extend({
        // The regular expressions that power the parsing engine
        parse: [
                // Match: [@value='test'], [@foo]
-               [ "\\[ *(@)S *([!*$^=]*) *Q\\]", 1 ],
+               "\\[ *(@)S *([!*$^=]*)Q\\]",
 
                // Match: [div], [div p]
-               [ "(\\[)Q\\]", 0 ],
+               "(\\[)Q\\]",
 
                // Match: :contains('foo')
-               [ "(:)S\\(Q\\)", 0 ],
+               "(:)S\\(Q\\)",
 
                // Match: :even, :last-chlid
-               [ "([:.#]*)S", 0 ]
+               "([:.#]*)S"
        ],
 
        filter: function(t,r,not) {
@@ -1566,21 +1792,28 @@ jQuery.extend({
                        var p = jQuery.parse;
 
                        for ( var i = 0; i < p.length; i++ ) {
-                               var re = new RegExp( "^" + p[i][0]
-
+                               // get number for backreference
+                               var br = 0;
+                               if(p[i].indexOf('Q') != -1){
+                                       br = p[i].replace(/\\\(/g,'').match(/\(|S/g).length+1;
+                               }
+                               var re = new RegExp( "^" + p[i]
+                       
                                        // Look for a string-like sequence
                                        .replace( 'S', "([a-z*_-][a-z0-9_-]*)" )
 
                                        // Look for something (optionally) enclosed with quotes
-                                       .replace( 'Q', " *'?\"?([^'\"]*?)'?\"? *" ), "i" );
+                                       .replace( 'Q', " *('|\"|)([^'\"]*?)\\"+br+" *" ), "i" );
 
                                var m = re.exec( t );
 
                                if ( m ) {
                                        // Re-organize the match
-                                       if ( p[i][1] )
-                                               m = ["", m[1], m[3], m[2], m[4]];
-
+                                       if(br == 4){
+                                               m = ["",m[1], m[3], m[2], m[5]];
+                                       } else if(br != 0) {
+                                               m.splice(br,1);
+                                       }
                                        // Remove what we just matched
                                        t = t.replace( re, "" );
 
@@ -1617,6 +1850,9 @@ jQuery.extend({
        /**
         * Remove the whitespace from the beginning and end of a string.
         *
+        * @example $.trim("  hello, how are you?  ");
+        * @result "hello, how are you?"
+        *
         * @name $.trim
         * @type String
         * @param String str The string to trim.
@@ -1676,12 +1912,20 @@ jQuery.extend({
        },
 
        /**
-        * Merge two arrays together, removing all duplicates.
+        * Merge two arrays together, removing all duplicates. The final order
+        * or the new array is: All the results from the first array, followed
+        * by the unique results from the second array.
+        *
+        * @example $.merge( [0,1,2], [2,3,4] )
+        * @result [0,1,2,3,4]
+        *
+        * @example $.merge( [3,2,1], [4,3,2] )
+        * @result [3,2,1,4]
         *
         * @name $.merge
         * @type Array
-        * @param Array a The first array to merge.
-        * @param Array b The second array to merge.
+        * @param Array first The first array to merge.
+        * @param Array second The second array to merge.
         * @cat Javascript
         */
        merge: function(first, second) {
@@ -1711,9 +1955,16 @@ jQuery.extend({
        },
 
        /**
-        * Remove items that aren't matched in an array. The function passed
-        * in to this method will be passed two arguments: 'a' (which is the
-        * array item) and 'i' (which is the index of the item in the array).
+        * Filter items out of an array, by using a filter function.
+        * The specified function will be passed two arguments: The
+        * current array item and the index of the item in the array. The
+        * function should return 'true' if you wish to keep the item in
+        * the array, false if it should be removed.
+        *
+        * @example $.grep( [0,1,2], function(i){
+        *   return i > 0;
+        * });
+        * @result [1, 2]
         *
         * @name $.grep
         * @type Array
@@ -1740,12 +1991,27 @@ jQuery.extend({
        },
 
        /**
-        * Translate all items in array to another array of items. The translation function
-        * that is provided to this method is passed one argument: 'a' (the item to be
-        * translated). If an array is returned, that array is mapped out and merged into
-        * the full array. Additionally, returning 'null' or 'undefined' will delete the item
-        * from the array. Both of these changes imply that the size of the array may not
-        * be the same size upon completion, as it was when it started.
+        * Translate all items in an array to another array of items. 
+        * The translation function that is provided to this method is 
+        * called for each item in the array and is passed one argument: 
+        * The item to be translated. The function can then return:
+        * The translated value, 'null' (to remove the item), or 
+        * an array of values - which will be flattened into the full array.
+        *
+        * @example $.map( [0,1,2], function(i){
+        *   return i + 4;
+        * });
+        * @result [4, 5, 6]
+        *
+        * @example $.map( [0,1,2], function(i){
+        *   return i > 0 ? i + 1 : null;
+        * });
+        * @result [2, 3]
+        * 
+        * @example $.map( [0,1,2], function(i){
+        *   return [ i, i + 1 ];
+        * });
+        * @result [0, 1, 1, 2, 2, 3]
         *
         * @name $.map
         * @type Array
@@ -1872,8 +2138,11 @@ jQuery.extend({
 
                        var c = this.events[event.type];
 
+                       var args = [].slice.call( arguments, 1 );
+                       args.unshift( event );
+
                        for ( var j in c ) {
-                               if ( c[j].apply( this, [event] ) === false ) {
+                               if ( c[j].apply( this, args ) === false ) {
                                        event.preventDefault();
                                        event.stopPropagation();
                                        returnValue = false;
@@ -2289,6 +2558,9 @@ jQuery.macros = {
                 * @before <input type="text" value="some text"/>
                 * @result "some text"
                 *
+                * @test ok( $("#text1").val() == "Test", "Check for value of input element" );
+                * @test ok( !$("#text1").val() == "", "Check for value of input element" );
+                *
                 * @name val
                 * @type String
                 * @cat DOM/Attributes
@@ -2301,6 +2573,11 @@ jQuery.macros = {
                 * @before <input type="text" value="some text"/>
                 * @result <input type="text" value="test"/>
                 *
+                * @test document.getElementById('text1').value = "bla";
+                * ok( $("#text1").val() == "bla", "Check for modified value of input element" );
+                * $("#text1").val('test');
+                * ok ( document.getElementById('text1').value == "test", "Check for modified (via val(String)) value of input element" );
+                *
                 * @name val
                 * @type jQuery
                 * @param String val Set the property to the specified value.
@@ -2656,6 +2933,8 @@ jQuery.macros = {
                 * @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
                 * @result [ <p>Hello</p>, <p>And Again</p> ]
                 *
+                * @test isSet( $("#en").siblings().get(), q("sndp", "sap"), "Check for siblings" ); 
+                *
                 * @name siblings
                 * @type jQuery
                 * @cat DOM/Traversing
@@ -2669,6 +2948,9 @@ jQuery.macros = {
                 * @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p>
                 * @result [ <p class="selected">Hello Again</p> ]
                 *
+                * @test isSet( $("#sndp").siblings("[code]").get(), q("sap"), "Check for filtered siblings (has code child element)" ); 
+                * @test isSet( $("#sndp").siblings("[a]").get(), q("en", "sap"), "Check for filtered siblings (has anchor child element)" );
+                *
                 * @name siblings
                 * @type jQuery
                 * @param String expr An expression to filter the sibling Elements with
@@ -2902,24 +3184,31 @@ jQuery.macros = {
                },
 
                /**
-                * Binds a particular event (like click) to a each of a set of match elements.
-                *
-                * @example $("p").bind( "click", function() { alert("Hello"); } )
+                * Binds a handler to a particular event (like click) for each matched element.
+                * The event handler is passed an event object that you can use to prevent
+                * default behaviour. To stop both default action and event bubbling, your handler
+                * has to return false.
+                *
+                * @example $("p").bind( "click", function() {
+                *   alert( $(this).text() );
+                * } )
                 * @before <p>Hello</p>
-                * @result [ <p>Hello</p> ]
-                *
-                * Cancel a default action and prevent it from bubbling by returning false
-                * from your function.
+                * @result alert("Hello")
                 *
                 * @example $("form").bind( "submit", function() { return false; } )
+                * @desc Cancel a default action and prevent it from bubbling by returning false
+                * from your function.
                 *
-                * Cancel a default action by using the preventDefault method.
-                *
-                * @example $("form").bind( "submit", function() { e.preventDefault(); } )
+                * @example $("form").bind( "submit", function(event) {
+                *   event.preventDefault();
+                * } );
+                * @desc Cancel only the default action by using the preventDefault method.
                 *
-                * Stop an event from bubbling by using the stopPropogation method.
                 *
-                * @example $("form").bind( "submit", function() { e.stopPropogation(); } )
+                * @example $("form").bind( "submit", function(event) {
+                *   event.stopPropagation();
+                * } )
+                * @desc Stop only an event from bubbling by using the stopPropagation method.
                 *
                 * @name bind
                 * @type jQuery