@@ -162,7 +162,7 @@ test("attr(Hash)", function() {
162162} ) ;
163163
164164test ( "attr(String, Object)" , function ( ) {
165- expect ( 69 ) ;
165+ expect ( 73 ) ;
166166
167167 var div = jQuery ( "div" ) . attr ( "foo" , "bar" ) ,
168168 fail = false ;
@@ -230,13 +230,20 @@ test("attr(String, Object)", function() {
230230 jQuery ( "#name" ) . attr ( "maxLength" , "10" ) ;
231231 equals ( document . getElementById ( "name" ) . maxLength , 10 , "Set maxlength attribute" ) ;
232232
233- var $text = jQuery ( "#text1" ) . attr ( "autofocus" , true ) ;
234- if ( "autofocus" in $text [ 0 ] ) {
235- equals ( $text . attr ( "autofocus" ) , "autofocus" , "Set boolean attributes to the same name" ) ;
236- } else {
237- equals ( $text . attr ( "autofocus" ) , undefined , "autofocus stays undefined in browsers that do not support it(F<4)" ) ;
238- }
239- equals ( $text . attr ( "autofocus" , false ) . attr ( "autofocus" ) , undefined , "Setting autofocus attribute to false removes it" ) ;
233+ // HTML5 boolean attributes
234+ var $text = jQuery ( "#text1" ) . attr ( {
235+ "autofocus" : true ,
236+ "required" : true
237+ } ) ;
238+ equal ( $text . attr ( "autofocus" ) , "autofocus" , "Set boolean attributes to the same name" ) ;
239+ equal ( $text . attr ( "autofocus" , false ) . attr ( "autofocus" ) , undefined , "Setting autofocus attribute to false removes it" ) ;
240+ equal ( $text . attr ( "required" ) , "required" , "Set boolean attributes to the same name" ) ;
241+ equal ( $text . attr ( "required" , false ) . attr ( "required" ) , undefined , "Setting required attribute to false removes it" ) ;
242+
243+ var $details = jQuery ( "<details open></details>" ) . appendTo ( "#qunit-fixture" ) ;
244+ equal ( $details . attr ( "open" ) , "open" , "open attribute presense indicates true" ) ;
245+ equal ( $details . attr ( "open" , false ) . attr ( "open" ) , undefined , "Setting open attribute to false removes it" ) ;
246+
240247 equals ( $text . attr ( "data-something" , true ) . data ( "something" ) , true , "Setting data attributes are not affected by boolean settings" ) ;
241248 equals ( $text . attr ( "data-another" , false ) . data ( "another" ) , false , "Setting data attributes are not affected by boolean settings" ) ;
242249 equals ( $text . attr ( "aria-disabled" , false ) . attr ( "aria-disabled" ) , "false" , "Setting aria attributes are not affected by boolean settings" ) ;
0 commit comments