]> source.dussan.org Git - jquery.git/commitdiff
Fix #13835: classes separated by form feed
authorRichard Gibson <richard.gibson@gmail.com>
Tue, 14 May 2013 01:55:00 +0000 (21:55 -0400)
committerRichard Gibson <richard.gibson@gmail.com>
Tue, 14 May 2013 01:55:18 +0000 (21:55 -0400)
(cherry picked from commit d8a35011ec05ed3493a85c1bd699902893cd437c)

src/attributes.js
test/unit/attributes.js

index 8a6bf565925adde8b0ad2a46f4da4bcf2c7ed04b..4ea1bd5cf62cf34c87f653bf8c42ac23736b8864 100644 (file)
@@ -1,5 +1,5 @@
 var nodeHook, boolHook,
-       rclass = /[\t\r\n]/g,
+       rclass = /[\t\r\n\f]/g,
        rreturn = /\r/g,
        rfocusable = /^(?:input|select|textarea|button|object)$/i,
        rclickable = /^(?:a|area)$/i,
index b913ce960500eaab5fc0bc0d9297dacd0c23787c..aa9d3b48cb3e4a2c5cb87e3b2ff39ba6475046b4 100644 (file)
@@ -1357,6 +1357,26 @@ test( "contents().hasClass() returns correct values", function() {
        ok( !$contents.hasClass("undefined"), "Did not find 'undefined' in $contents (correctly)" );
 });
 
+test( "hasClass correctly interprets non-space separators (#13835)", function() {
+       expect( 4 );
+
+       var
+               map = {
+                       tab: "&#9;",
+                       "line-feed": "&#10;",
+                       "form-feed": "&#12;",
+                       "carriage-return": "&#13;"
+               },
+               classes = jQuery.map( map, function( separator, label ) {
+                       return " " + separator + label + separator + " ";
+               }),
+               $div = jQuery( "<div class='" + classes + "'></div>" );
+
+       jQuery.each( map, function( label ) {
+               ok( $div.hasClass( label ), label.replace( "-", " " ) );
+       });
+});
+
 test( "coords returns correct values in IE6/IE7, see #10828", function() {
        expect( 1 );