]> 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:00 +0000 (21:55 -0400)
src/attributes.js
test/unit/attributes.js

index ace917e91e25ca0ad02f7a07f5b3173e6634890a..f7525755f559f2765973dd27b1fef15558f3e582 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)$/i;
 
index 062dd504ca5aeaa5980b0fb7e5f78eadf1a6a3da..84ac8c2b28d00f5fba9fecf68284499648aebd90 100644 (file)
@@ -1353,6 +1353,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 );