Merge branch 't7578' of https://github.com/jitter/jquery into jitter-t7578
authorJohn Resig <jeresig@gmail.com>
Mon, 6 Dec 2010 22:06:26 +0000 (17:06 -0500)
committerJohn Resig <jeresig@gmail.com>
Mon, 6 Dec 2010 22:06:26 +0000 (17:06 -0500)
.gitattributes
src/attributes.js
src/core.js
src/event.js
test/data/text.php
test/delegatetest.html
test/unit/attributes.js
test/unit/core.js

index bcb36db..d6dc470 100644 (file)
@@ -1 +1,2 @@
-* crlf=input
+*     eol=lf
+*.jar binary
index 4824c29..b0e3601 100644 (file)
@@ -1,6 +1,6 @@
 (function( jQuery ) {
 
-var rclass = /[\n\t]/g,
+var rclass = /[\n\t\r]/g,
        rspaces = /\s+/,
        rreturn = /\r/g,
        rspecialurl = /^(?:href|src|style)$/,
@@ -205,7 +205,6 @@ jQuery.fn.extend({
                                if ( rradiocheck.test( elem.type ) && !jQuery.support.checkOn ) {
                                        return elem.getAttribute("value") === null ? "on" : elem.value;
                                }
-                               
 
                                // Everything else, we just grab the value
                                return (elem.value || "").replace(rreturn, "");
@@ -271,7 +270,7 @@ jQuery.extend({
                height: true,
                offset: true
        },
-               
+
        attr: function( elem, name, value, pass ) {
                // don't set attributes on text and comment nodes
                if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
@@ -289,88 +288,96 @@ jQuery.extend({
                // Try to normalize/fix the name
                name = notxml && jQuery.props[ name ] || name;
 
-               // These attributes require special treatment
-               var special = rspecialurl.test( name );
+               // Only do all the following if this is a node (faster for style)
+               if ( elem.nodeType === 1 ) {
+                       // These attributes require special treatment
+                       var special = rspecialurl.test( name );
+
+                       // Safari mis-reports the default selected property of an option
+                       // Accessing the parent's selectedIndex property fixes it
+                       if ( name === "selected" && !jQuery.support.optSelected ) {
+                               var parent = elem.parentNode;
+                               if ( parent ) {
+                                       parent.selectedIndex;
+
+                                       // Make sure that it also works with optgroups, see #5701
+                                       if ( parent.parentNode ) {
+                                               parent.parentNode.selectedIndex;
+                                       }
+                               }
+                       }
 
-               // Safari mis-reports the default selected property of an option
-               // Accessing the parent's selectedIndex property fixes it
-               if ( name === "selected" && !jQuery.support.optSelected ) {
-                       var parent = elem.parentNode;
-                       if ( parent ) {
-                               parent.selectedIndex;
+                       // If applicable, access the attribute via the DOM 0 way
+                       // 'in' checks fail in Blackberry 4.7 #6931
+                       if ( (name in elem || elem[ name ] !== undefined) && notxml && !special ) {
+                               if ( set ) {
+                                       // We can't allow the type property to be changed (since it causes problems in IE)
+                                       if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) {
+                                               jQuery.error( "type property can't be changed" );
+                                       }
+
+                                       if ( value === null ) {
+                                               if ( elem.nodeType === 1 ) {
+                                                       elem.removeAttribute( name );
+                                               }
 
-                               // Make sure that it also works with optgroups, see #5701
-                               if ( parent.parentNode ) {
-                                       parent.parentNode.selectedIndex;
+                                       } else {
+                                               elem[ name ] = value;
+                                       }
                                }
-                       }
-               }
 
-               // If applicable, access the attribute via the DOM 0 way
-               // 'in' checks fail in Blackberry 4.7 #6931
-               if ( (name in elem || elem[ name ] !== undefined) && notxml && !special ) {
-                       if ( set ) {
-                               // We can't allow the type property to be changed (since it causes problems in IE)
-                               if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) {
-                                       jQuery.error( "type property can't be changed" );
+                               // browsers index elements by id/name on forms, give priority to attributes.
+                               if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) {
+                                       return elem.getAttributeNode( name ).nodeValue;
                                }
 
-                               if ( value === null ) {
-                                       if ( elem.nodeType === 1 ) {
-                                               elem.removeAttribute( name );
-                                       }
+                               // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
+                               // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
+                               if ( name === "tabIndex" ) {
+                                       var attributeNode = elem.getAttributeNode( "tabIndex" );
 
-                               } else {
-                                       elem[ name ] = value;
+                                       return attributeNode && attributeNode.specified ?
+                                               attributeNode.value :
+                                               rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
+                                                       0 :
+                                                       undefined;
                                }
-                       }
 
-                       // browsers index elements by id/name on forms, give priority to attributes.
-                       if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) {
-                               return elem.getAttributeNode( name ).nodeValue;
+                               return elem[ name ];
                        }
 
-                       // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
-                       // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
-                       if ( name === "tabIndex" ) {
-                               var attributeNode = elem.getAttributeNode( "tabIndex" );
+                       if ( !jQuery.support.style && notxml && name === "style" ) {
+                               if ( set ) {
+                                       elem.style.cssText = "" + value;
+                               }
 
-                               return attributeNode && attributeNode.specified ?
-                                       attributeNode.value :
-                                       rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
-                                               0 :
-                                               undefined;
+                               return elem.style.cssText;
                        }
 
-                       return elem[ name ];
-               }
-
-               if ( !jQuery.support.style && notxml && name === "style" ) {
                        if ( set ) {
-                               elem.style.cssText = "" + value;
+                               // convert the value to a string (all browsers do this but IE) see #1070
+                               elem.setAttribute( name, "" + value );
                        }
 
-                       return elem.style.cssText;
-               }
+                       // Ensure that missing attributes return undefined
+                       // Blackberry 4.7 returns "" from getAttribute #6938
+                       if ( !elem.attributes[ name ] && (elem.hasAttribute && !elem.hasAttribute( name )) ) {
+                               return undefined;
+                       }
 
-               if ( set ) {
-                       // convert the value to a string (all browsers do this but IE) see #1070
-                       elem.setAttribute( name, "" + value );
-               }
+                       var attr = !jQuery.support.hrefNormalized && notxml && special ?
+                                       // Some attributes require a special call on IE
+                                       elem.getAttribute( name, 2 ) :
+                                       elem.getAttribute( name );
 
-               // Ensure that missing attributes return undefined
-               // Blackberry 4.7 returns "" from getAttribute #6938
-               if ( !elem.attributes[ name ] && (elem.hasAttribute && !elem.hasAttribute( name )) ) {
-                       return undefined;
+                       // Non-existent attributes return null, we normalize to undefined
+                       return attr === null ? undefined : attr;
                }
-
-               var attr = !jQuery.support.hrefNormalized && notxml && special ?
-                               // Some attributes require a special call on IE
-                               elem.getAttribute( name, 2 ) :
-                               elem.getAttribute( name );
-
-               // Non-existent attributes return null, we normalize to undefined
-               return attr === null ? undefined : attr;
+               // Handle everything which isn't a DOM element node
+               if ( set ) {
+                       elem[ name ] = value;
+               }
+               return elem[ name ];
        }
 });
 
index 9e1bfc6..18cd3a3 100644 (file)
@@ -215,7 +215,7 @@ jQuery.fn = jQuery.prototype = {
                        this.toArray() :
 
                        // Return just the object
-                       ( num < 0 ? this.slice(num)[ 0 ] : this[ num ] );
+                       ( num < 0 ? this[ this.length + num ] : this[ num ] );
        },
 
        // Take an array of elements and push it onto the stack
index 3cfc817..58a6953 100644 (file)
@@ -1075,8 +1075,8 @@ function liveHandler( event ) {
                events = events.events;
        }
 
-       // Make sure we avoid non-left-click bubbling in Firefox (#3861)
-       if ( event.liveFired === this || !events || !events.live || event.button && event.type === "click" ) {
+       // Make sure we avoid non-left-click bubbling in Firefox (#3861) and disabled elements in IE (#6911)
+       if ( event.liveFired === this || !events || !events.live || event.target.disabled || event.button && event.type === "click" ) {
                return;
        }
        
index c06ef4b..b9df4cf 100644 (file)
@@ -1,12 +1,12 @@
-Lorem ipsum dolor sit amet\r
-consectetuer adipiscing elit\r
-Sed lorem leo\r
-lorem leo consectetuer adipiscing elit\r
-Sed lorem leo\r
-rhoncus sit amet\r
-elementum at\r
-bibendum at, eros\r
-Cras at mi et tortor egestas vestibulum\r
-sed Cras at mi vestibulum\r
-Phasellus sed felis sit amet\r
-orci dapibus semper.\r
+Lorem ipsum dolor sit amet
+consectetuer adipiscing elit
+Sed lorem leo
+lorem leo consectetuer adipiscing elit
+Sed lorem leo
+rhoncus sit amet
+elementum at
+bibendum at, eros
+Cras at mi et tortor egestas vestibulum
+sed Cras at mi vestibulum
+Phasellus sed felis sit amet
+orci dapibus semper.
index b2840c1..327085c 100644 (file)
-<html>\r
-    <head>\r
-        <script src='../dist/jquery.js' type='text/javascript'></script>\r
-        <style>\r
-       .red {\r
-           background-color: red;\r
-           border: solid 3px red;\r
-       }\r
-        </style>\r
-    </head>\r
-    <body>\r
-        <h2>Change Tests</h2>\r
-        <table>\r
-           <tr>\r
-               <td>\r
-               Change each:\r
-               </td>\r
-               <td>\r
-               <select class='select_test'>\r
-                   <option value='one'>change me 1</option>\r
-                   <option value='two'>change me 2</option>\r
-                   <option value='three'>change me 3</option>\r
-               </select>\r
-               <select class='select_test'>\r
-                   <option value='one'>change me 1</option>\r
-                   <option value='two' selected="selected">change me 2</option>\r
-                   <option value='three'>change me 3</option>\r
-               </select>\r
-               </td>\r
-               <td>\r
-               <select class='mselect_test' multiple="multiple">\r
-                   <option value='one'>change me 1</option>\r
-                   <option value='two'>change me 2</option>\r
-                   <option value='three'>change me 3</option>\r
-               </select>\r
-               </td>\r
-               <td>\r
-               <input type="checkbox" class="checkbox_test" name="mycheckbox" id="checkbox1"/>\r
-               <label for="checkbox1">Checkbox 1</label><br/>\r
-               <input type="checkbox" class="checkbox_test" name="mycheckbox" id="checkbox2"/>\r
-               <label for="checkbox2">Checkbox 2</label>\r
-               <input type="checkbox" class="checkbox_test" name="mycheckbox" id="checkbox3" disabled="disabled"/>\r
-               <label for="checkbox3">Checkbox 3</label>\r
-               </td>\r
-               </td>\r
-               </td>\r
-               <td>\r
-               <input type="radio" class="radio_test" name="myradio" id="radio1"/>\r
-               <label for="radio1">Radio1</label><br/>\r
-               <input type="radio" class="radio_test" name="myradio" id="radio2"/>\r
-               <label for="radio2">Radio2</label>\r
-               <input type="radio" class="radio_test" name="myradio" id="radio3" disabled="disabled"/>\r
-               <label for="radio3">Radio3</label>\r
-               </td>\r
-               <td>\r
-               <input class="file_test" id="file1" type="file"/>\r
-               <td>\r
-               <input class='test' value='' id='input' size='10' />\r
-               <input class='test' value='test' id='input2' size='10' readonly="readonly" />\r
-               </td>\r
-               <td>\r
-               <textarea rows='2'></textarea>\r
-               </td>\r
-               <td>$(document).bind('change')</td>\r
-           </tr>\r
-           <tr>\r
-               <td>Live:</td>\r
-               <td id='select' class="red">SELECT</td>\r
-               <td id='mselect' class="red">MULTI</td>\r
-               <td id='checkbox' class="red">CHECKBOX</td>\r
-               <td id='radio' class="red">RADIO</td>\r
-               <td id='file' class="red">FILE</td>\r
-               <td id='text' class="red">TEXT</td>\r
-               <td id='textarea' class="red">TEXTAREA</td>\r
-               <td id='boundChange' class="red">DOCUMENT</td>\r
-           </tr>\r
-           <tr>\r
-               <td>Bind:</td>\r
-               <td id='selectbind' class="red">SELECT</td>\r
-               <td id='mselectbind' class="red">MULTI</td>\r
-               <td id='checkboxbind' class="red">CHECKBOX</td>\r
-               <td id='radiobind' class="red">RADIO</td>\r
-               <td id='filebind' class="red">FILE</td>\r
-               <td id='textbind' class="red">TEXT</td>\r
-               <td id='textareabind' class="red">TEXTAREA</td>\r
-           </tr>\r
-           <tr>\r
-               <td>Focusin:</td>\r
-               <td id='selectfocus' class="red">SELECT</td>\r
-               <td id='mselectfocus' class="red">MULTI</td>\r
-               <td id='checkboxfocus' class="red">CHECKBOX</td>\r
-               <td id='radiofocus' class="red">RADIO</td>\r
-               <td id='filefocus' class="red">FILE</td>\r
-               <td id='textfocus' class="red">TEXT</td>\r
-               <td id='textareafocus' class="red">TEXTAREA</td>\r
-               <td id='boundFocus' class="red">DOCUMENT</td>\r
-           </tr>\r
-           <tr>\r
-               <td>Focusout:</td>\r
-               <td id='selectblur' class="red">SELECT</td>\r
-               <td id='mselectblur' class="red">MULTI</td>\r
-               <td id='checkboxblur' class="red">CHECKBOX</td>\r
-               <td id='radioblur' class="red">RADIO</td>\r
-               <td id='fileblur' class="red">FILE</td>\r
-               <td id='textblur' class="red">TEXT</td>\r
-               <td id='textareablur' class="red">TEXTAREA</td>\r
-               <td id='boundBlur' class="red">DOCUMENT</td>\r
-           </tr>\r
-           <tr>\r
-               <td>Live Focus:</td>\r
-               <td id='selectlfocus' class="red">SELECT</td>\r
-               <td id='mselectlfocus' class="red">MULTI</td>\r
-               <td id='checkboxlfocus' class="red">CHECKBOX</td>\r
-               <td id='radiolfocus' class="red">RADIO</td>\r
-               <td id='filelfocus' class="red">FILE</td>\r
-               <td id='textlfocus' class="red">TEXT</td>\r
-               <td id='textarealfocus' class="red">TEXTAREA</td>\r
-           </tr>\r
-           <tr>\r
-               <td>Live Blur:</td>\r
-               <td id='selectlblur' class="red">SELECT</td>\r
-               <td id='mselectlblur' class="red">MULTI</td>\r
-               <td id='checkboxlblur' class="red">CHECKBOX</td>\r
-               <td id='radiolblur' class="red">RADIO</td>\r
-               <td id='filelblur' class="red">FILE</td>\r
-               <td id='textlblur' class="red">TEXT</td>\r
-               <td id='textarealblur' class="red">TEXTAREA</td>\r
-           </tr>\r
-        </table>\r
-        <h2>Submit Tests</h2>\r
-        <table>\r
-       <tr>\r
-           <td>\r
-               Submit each:\r
-           </td>\r
-           <td>\r
-               <form action="" id="text_submit">\r
-               <input class='test' type='text' value='Key Return To Submit'/>\r
-               </form>\r
-           </td>\r
-           <td>\r
-               <form action="" id="password_submit">\r
-               <input class='test' type='password' value=''/>\r
-               </form>\r
-           </td>\r
-           <td>\r
-               <form action="" id="submit_submit">\r
-               <input type='submit' value="Click Me To Submit" />\r
-               </form>\r
-           </td>\r
-           <td>$(document).bind('submit')</td>\r
-       </tr>\r
-       <tr>\r
-               <td>Results:</td>\r
-               <td id='textSubmit' class="red">TEXT</td>\r
-               <td id='passwordSubmit' class="red">PASSWORD</td>\r
-               <td id='submitSubmit' class="red">BUTTON</td>\r
-               <td id='boundSubmit' class="red">DOCUMENT</td>\r
-       </tr>\r
-        </table>\r
-\r
-       <ul id="log"></ul>\r
-\r
-        <script type='text/javascript'>\r
-       jQuery.fn.addChangeTest = function( id, prevent ) {\r
-               this.bind("focusin", function(){\r
-                       jQuery(id + "focus").blink();\r
-               }).bind("focusout", function(){\r
-                       jQuery(id + "blur").blink();\r
-               });\r
-\r
-               this.bind("focus", function(){\r
-                       jQuery(id + "lfocus").blink();\r
-               }).bind("blur", function(){\r
-                       jQuery(id + "lblur").blink();\r
-               });\r
-\r
-               return this.bind("change", function(e){\r
-                       jQuery(id + "bind").blink();\r
-               }).live("change", function(e){\r
-                       if ( prevent ) {\r
-                               e.preventDefault();\r
-                       }\r
-\r
-                       jQuery(id).blink();\r
-               });\r
-       };\r
-\r
-       jQuery.fn.addSubmitTest = function( id, prevent ) {\r
-               return this.live("submit", function(e){\r
-                       if ( prevent ) {\r
-                               e.preventDefault();\r
-                       }\r
-\r
-                       jQuery(id).blink();\r
-               });\r
-       };\r
-\r
-       jQuery.fn.blink = function(){\r
-               return this.css("backgroundColor","green").css("border","solid 3px green").delay(700).queue(function(next){\r
-                       jQuery(this).css("backgroundColor","");\r
-                       next();\r
-               });\r
-       };\r
-\r
-       $(document).bind("focusin", function() {\r
-               jQuery("#boundFocus").blink();\r
-       });\r
-       \r
-       $(document).bind("focusout", function() {\r
-               jQuery("#boundBlur").blink();\r
-       });\r
-\r
-       $("td.red").live("hover", function(e) {\r
-               if ( e.type === "mouseenter" ) {\r
-                       $(this).css("backgroundColor","green");\r
-               } else {\r
-                       $(this).css("backgroundColor","");\r
-               }\r
-       });\r
-\r
-       $(".select_test").addChangeTest("#select");\r
-       $(".mselect_test").addChangeTest("#mselect");\r
-       $(".checkbox_test").addChangeTest("#checkbox");\r
-       $(".radio_test").addChangeTest("#radio");\r
-       $(".file_test").addChangeTest("#file");\r
-       $('textarea').addChangeTest("#textarea");\r
-       $('#input').addChangeTest("#text");\r
-       $(document).bind("change", function(){\r
-               jQuery("#boundChange").blink();\r
-       });\r
-       \r
-       $("#text_submit").addSubmitTest("#textSubmit", true);\r
-       $("#password_submit").addSubmitTest("#passwordSubmit", true);\r
-       $("#submit_submit").addSubmitTest("#submitSubmit", true);\r
-       $(document).bind("submit", function(){\r
-               jQuery("#boundSubmit").blink();\r
-       });\r
-       \r
-        </script>\r
-    </body>\r
-</html>\r
+<html>
+    <head>
+        <script src='../dist/jquery.js' type='text/javascript'></script>
+        <style>
+       .red {
+           background-color: red;
+           border: solid 3px red;
+       }
+        </style>
+    </head>
+    <body>
+        <h2>Change Tests</h2>
+        <table>
+           <tr>
+               <td>
+               Change each:
+               </td>
+               <td>
+               <select class='select_test'>
+                   <option value='one'>change me 1</option>
+                   <option value='two'>change me 2</option>
+                   <option value='three'>change me 3</option>
+               </select>
+               <select class='select_test'>
+                   <option value='one'>change me 1</option>
+                   <option value='two' selected="selected">change me 2</option>
+                   <option value='three'>change me 3</option>
+               </select>
+               </td>
+               <td>
+               <select class='mselect_test' multiple="multiple">
+                   <option value='one'>change me 1</option>
+                   <option value='two'>change me 2</option>
+                   <option value='three'>change me 3</option>
+               </select>
+               </td>
+               <td>
+               <input type="checkbox" class="checkbox_test" name="mycheckbox" id="checkbox1"/>
+               <label for="checkbox1">Checkbox 1</label><br/>
+               <input type="checkbox" class="checkbox_test" name="mycheckbox" id="checkbox2"/>
+               <label for="checkbox2">Checkbox 2</label>
+               <input type="checkbox" class="checkbox_test" name="mycheckbox" id="checkbox3" disabled="disabled"/>
+               <label for="checkbox3">Checkbox 3</label>
+               </td>
+               </td>
+               </td>
+               <td>
+               <input type="radio" class="radio_test" name="myradio" id="radio1"/>
+               <label for="radio1">Radio1</label><br/>
+               <input type="radio" class="radio_test" name="myradio" id="radio2"/>
+               <label for="radio2">Radio2</label>
+               <input type="radio" class="radio_test" name="myradio" id="radio3" disabled="disabled"/>
+               <label for="radio3">Radio3</label>
+               </td>
+               <td>
+               <input class="file_test" id="file1" type="file"/>
+               <td>
+               <input class='test' value='' id='input' size='10' />
+               <input class='test' value='test' id='input2' size='10' readonly="readonly" />
+               </td>
+               <td>
+               <textarea rows='2'></textarea>
+               </td>
+               <td>$(document).bind('change')</td>
+           </tr>
+           <tr>
+               <td>Live:</td>
+               <td id='select' class="red">SELECT</td>
+               <td id='mselect' class="red">MULTI</td>
+               <td id='checkbox' class="red">CHECKBOX</td>
+               <td id='radio' class="red">RADIO</td>
+               <td id='file' class="red">FILE</td>
+               <td id='text' class="red">TEXT</td>
+               <td id='textarea' class="red">TEXTAREA</td>
+               <td id='boundChange' class="red">DOCUMENT</td>
+           </tr>
+           <tr>
+               <td>Bind:</td>
+               <td id='selectbind' class="red">SELECT</td>
+               <td id='mselectbind' class="red">MULTI</td>
+               <td id='checkboxbind' class="red">CHECKBOX</td>
+               <td id='radiobind' class="red">RADIO</td>
+               <td id='filebind' class="red">FILE</td>
+               <td id='textbind' class="red">TEXT</td>
+               <td id='textareabind' class="red">TEXTAREA</td>
+           </tr>
+           <tr>
+               <td>Focusin:</td>
+               <td id='selectfocus' class="red">SELECT</td>
+               <td id='mselectfocus' class="red">MULTI</td>
+               <td id='checkboxfocus' class="red">CHECKBOX</td>
+               <td id='radiofocus' class="red">RADIO</td>
+               <td id='filefocus' class="red">FILE</td>
+               <td id='textfocus' class="red">TEXT</td>
+               <td id='textareafocus' class="red">TEXTAREA</td>
+               <td id='boundFocus' class="red">DOCUMENT</td>
+           </tr>
+           <tr>
+               <td>Focusout:</td>
+               <td id='selectblur' class="red">SELECT</td>
+               <td id='mselectblur' class="red">MULTI</td>
+               <td id='checkboxblur' class="red">CHECKBOX</td>
+               <td id='radioblur' class="red">RADIO</td>
+               <td id='fileblur' class="red">FILE</td>
+               <td id='textblur' class="red">TEXT</td>
+               <td id='textareablur' class="red">TEXTAREA</td>
+               <td id='boundBlur' class="red">DOCUMENT</td>
+           </tr>
+           <tr>
+               <td>Live Focus:</td>
+               <td id='selectlfocus' class="red">SELECT</td>
+               <td id='mselectlfocus' class="red">MULTI</td>
+               <td id='checkboxlfocus' class="red">CHECKBOX</td>
+               <td id='radiolfocus' class="red">RADIO</td>
+               <td id='filelfocus' class="red">FILE</td>
+               <td id='textlfocus' class="red">TEXT</td>
+               <td id='textarealfocus' class="red">TEXTAREA</td>
+           </tr>
+           <tr>
+               <td>Live Blur:</td>
+               <td id='selectlblur' class="red">SELECT</td>
+               <td id='mselectlblur' class="red">MULTI</td>
+               <td id='checkboxlblur' class="red">CHECKBOX</td>
+               <td id='radiolblur' class="red">RADIO</td>
+               <td id='filelblur' class="red">FILE</td>
+               <td id='textlblur' class="red">TEXT</td>
+               <td id='textarealblur' class="red">TEXTAREA</td>
+           </tr>
+        </table>
+        <h2>Submit Tests</h2>
+        <table>
+       <tr>
+           <td>
+               Submit each:
+           </td>
+           <td>
+               <form action="" id="text_submit">
+               <input class='test' type='text' value='Key Return To Submit'/>
+               </form>
+           </td>
+           <td>
+               <form action="" id="password_submit">
+               <input class='test' type='password' value=''/>
+               </form>
+           </td>
+           <td>
+               <form action="" id="submit_submit">
+               <input type='submit' value="Click Me To Submit" />
+               </form>
+           </td>
+           <td>$(document).bind('submit')</td>
+       </tr>
+       <tr>
+               <td>Results:</td>
+               <td id='textSubmit' class="red">TEXT</td>
+               <td id='passwordSubmit' class="red">PASSWORD</td>
+               <td id='submitSubmit' class="red">BUTTON</td>
+               <td id='boundSubmit' class="red">DOCUMENT</td>
+       </tr>
+        </table>
+
+       <ul id="log"></ul>
+
+        <script type='text/javascript'>
+       jQuery.fn.addChangeTest = function( id, prevent ) {
+               this.bind("focusin", function(){
+                       jQuery(id + "focus").blink();
+               }).bind("focusout", function(){
+                       jQuery(id + "blur").blink();
+               });
+
+               this.bind("focus", function(){
+                       jQuery(id + "lfocus").blink();
+               }).bind("blur", function(){
+                       jQuery(id + "lblur").blink();
+               });
+
+               return this.bind("change", function(e){
+                       jQuery(id + "bind").blink();
+               }).live("change", function(e){
+                       if ( prevent ) {
+                               e.preventDefault();
+                       }
+
+                       jQuery(id).blink();
+               });
+       };
+
+       jQuery.fn.addSubmitTest = function( id, prevent ) {
+               return this.live("submit", function(e){
+                       if ( prevent ) {
+                               e.preventDefault();
+                       }
+
+                       jQuery(id).blink();
+               });
+       };
+
+       jQuery.fn.blink = function(){
+               return this.css("backgroundColor","green").css("border","solid 3px green").delay(700).queue(function(next){
+                       jQuery(this).css("backgroundColor","");
+                       next();
+               });
+       };
+
+       $(document).bind("focusin", function() {
+               jQuery("#boundFocus").blink();
+       });
+       
+       $(document).bind("focusout", function() {
+               jQuery("#boundBlur").blink();
+       });
+
+       $("td.red").live("hover", function(e) {
+               if ( e.type === "mouseenter" ) {
+                       $(this).css("backgroundColor","green");
+               } else {
+                       $(this).css("backgroundColor","");
+               }
+       });
+
+       $(".select_test").addChangeTest("#select");
+       $(".mselect_test").addChangeTest("#mselect");
+       $(".checkbox_test").addChangeTest("#checkbox");
+       $(".radio_test").addChangeTest("#radio");
+       $(".file_test").addChangeTest("#file");
+       $('textarea').addChangeTest("#textarea");
+       $('#input').addChangeTest("#text");
+       $(document).bind("change", function(){
+               jQuery("#boundChange").blink();
+       });
+       
+       $("#text_submit").addSubmitTest("#textSubmit", true);
+       $("#password_submit").addSubmitTest("#passwordSubmit", true);
+       $("#submit_submit").addSubmitTest("#submitSubmit", true);
+       $(document).bind("submit", function(){
+               jQuery("#boundSubmit").blink();
+       });
+       
+        </script>
+    </body>
+</html>
index 2d0a0d6..d17653d 100644 (file)
@@ -4,7 +4,7 @@ var bareObj = function(value) { return value; };
 var functionReturningObj = function(value) { return (function() { return value; }); };
 
 test("attr(String)", function() {
-       expect(31);
+       expect(37);
 
        // This one sometimes fails randomly ?!
        equals( jQuery('#text1').attr('value'), "Test", 'Check for value attribute' );
@@ -67,6 +67,14 @@ test("attr(String)", function() {
        ok( jQuery().attr("doesntexist") === undefined, "Make sure undefined is returned when no element is there." );
 
        equals( jQuery(document).attr("nodeName"), "#document", "attr works correctly on document nodes (bug #7451)." );
+
+       var attributeNode = document.createAttribute("irrelevant"),
+               commentNode = document.createComment("some comment"),
+               textNode = document.createTextNode("some text"),
+               obj = {};
+       jQuery.each( [document, attributeNode, commentNode, textNode, obj, "#firstp"], function( i, ele ) {
+               strictEqual( jQuery(ele).attr("nonexisting"), undefined, "attr works correctly for non existing attributes (bug #7500)." );
+       });
 });
 
 if ( !isLocal ) {
@@ -100,7 +108,7 @@ test("attr(Hash)", function() {
 });
 
 test("attr(String, Object)", function() {
-       expect(24);
+       expect(30);
 
        var div = jQuery("div").attr("foo", "bar"),
                fail = false;
@@ -134,6 +142,25 @@ test("attr(String, Object)", function() {
        jQuery("#name").attr('maxLength', '10');
        equals( document.getElementById('name').maxLength, '10', 'Set maxlength attribute' );
 
+       var attributeNode = document.createAttribute("irrelevant"),
+               commentNode = document.createComment("some comment"),
+               textNode = document.createTextNode("some text"),
+               obj = {};
+       jQuery.each( [document, attributeNode, obj, "#firstp"], function( i, ele ) {
+               var $ele = jQuery( ele );
+               $ele.attr( "nonexisting", "foo" );
+               equal( $ele.attr("nonexisting"), "foo", "attr(name, value) works correctly for non existing attributes (bug #7500)." );
+       });
+       jQuery.each( [commentNode, textNode], function( i, ele ) {
+               var $ele = jQuery( ele );
+               $ele.attr( "nonexisting", "foo" );
+               strictEqual( $ele.attr("nonexisting"), undefined, "attr(name, value) works correctly on comment and text nodes (bug #7500)." );
+       });
+       //cleanup
+       jQuery.each( [document, "#firstp"], function( i, ele ) {
+               jQuery( ele ).removeAttr("nonexisting");
+       });
+
        var table = jQuery('#table').append("<tr><td>cell</td></tr><tr><td>cell</td><td>cell</td></tr><tr><td>cell</td><td>cell</td></tr>"),
                td = table.find('td:first');
        td.attr("rowspan", "2");
@@ -304,8 +331,26 @@ test("attr('tabindex', value)", function() {
 });
 
 test("removeAttr(String)", function() {
-       expect(1);
+       expect(7);
        equals( jQuery('#mark').removeAttr( "class" )[0].className, "", "remove class" );
+
+       var attributeNode = document.createAttribute("irrelevant"),
+               commentNode = document.createComment("some comment"),
+               textNode = document.createTextNode("some text"),
+               obj = {};
+       //removeAttr only really removes on DOM element nodes handle all other seperatyl
+       strictEqual( jQuery( "#firstp" ).attr( "nonexisting", "foo" ).removeAttr( "nonexisting" )[0].nonexisting, undefined, "removeAttr works correctly on DOM element nodes" );
+
+       jQuery.each( [document, attributeNode, obj], function( i, ele ) {
+               var $ele = jQuery( ele );
+               $ele.attr( "nonexisting", "foo" ).removeAttr( "nonexisting" );
+               strictEqual( ele.nonexisting, "", "removeAttr works correctly on non DOM element nodes (bug #7500)." );
+       });
+       jQuery.each( [commentNode, textNode], function( i, ele ) {
+               $ele = jQuery( ele );
+               $ele.attr( "nonexisting", "foo" ).removeAttr( "nonexisting" );
+               strictEqual( ele.nonexisting, undefined, "removeAttr works correctly on non DOM element nodes (bug #7500)." );
+       });
 });
 
 test("val()", function() {
@@ -719,7 +764,7 @@ test("toggleClass(Fucntion[, boolean]) with incoming value", function() {
 });
 
 test("addClass, removeClass, hasClass", function() {
-       expect(14);
+       expect(17);
  
        var jq = jQuery("<p>Hi</p>"), x = jq[0];
  
@@ -739,12 +784,14 @@ test("addClass, removeClass, hasClass", function() {
        ok( jq.hasClass("hi"), "Check has1" );
        ok( jq.hasClass("bar"), "Check has2" );
  
-       var jq = jQuery("<p class='class1\nclass2\tcla.ss3\n'></p>");
-       ok( jq.hasClass("class1"), "Check hasClass with carriage return" );
-       ok( jq.is(".class1"), "Check is with carriage return" );
+       var jq = jQuery("<p class='class1\nclass2\tcla.ss3\n\rclass4'></p>");
+       ok( jq.hasClass("class1"), "Check hasClass with line feed" );
+       ok( jq.is(".class1"), "Check is with line feed" );
        ok( jq.hasClass("class2"), "Check hasClass with tab" );
        ok( jq.is(".class2"), "Check is with tab" );
        ok( jq.hasClass("cla.ss3"), "Check hasClass with dot" );
+       ok( jq.hasClass("class4"), "Check hasClass with carriage return" );
+       ok( jq.is(".class4"), "Check is with carriage return" );
  
        jq.removeClass("class2");
        ok( jq.hasClass("class2")==false, "Check the class has been properly removed" );
@@ -752,4 +799,6 @@ test("addClass, removeClass, hasClass", function() {
        ok( jq.hasClass("cla.ss3"), "Check the dotted class has not been removed" );
        jq.removeClass("cla.ss3");
        ok( jq.hasClass("cla.ss3")==false, "Check the dotted class has been removed" );
+       jq.removeClass("class4");
+       ok( jq.hasClass("class4")==false, "Check the class has been properly removed" );
 });
index 7ef2ad7..7057783 100644 (file)
@@ -547,15 +547,15 @@ test("toArray()", function() {
 })
 
 test("get(Number)", function() {
-       expect(1);
+       expect(2);
        equals( jQuery("p").get(0), document.getElementById("firstp"), "Get A Single Element" );
+       strictEqual( jQuery("#firstp").get(1), undefined, "Try get with index larger elements count" );
 });
 
 test("get(-Number)",function() {
-       expect(1);
-       equals( jQuery("p").get(-1),
-               document.getElementById("first"),
-               "Get a single element with negative index" )
+       expect(2);
+       equals( jQuery("p").get(-1), document.getElementById("first"), "Get a single element with negative index" );
+       strictEqual( jQuery("#firstp").get(-2), undefined, "Try get with index negative index larger then elements count" );
 })
 
 test("each(Function)", function() {