@@ -527,6 +527,61 @@ test("prop(String, Object)", function() {
527527 jQuery ( document ) . removeProp ( "nonexisting" ) ;
528528} ) ;
529529
530+ test ( "prop('tabindex')" , function ( ) {
531+ expect ( 8 ) ;
532+
533+ // elements not natively tabbable
534+ equals ( jQuery ( "#listWithTabIndex" ) . prop ( "tabindex" ) , 5 , "not natively tabbable, with tabindex set to 0" ) ;
535+ equals ( jQuery ( "#divWithNoTabIndex" ) . prop ( "tabindex" ) , undefined , "not natively tabbable, no tabindex set" ) ;
536+
537+ // anchor with href
538+ equals ( jQuery ( "#linkWithNoTabIndex" ) . prop ( "tabindex" ) , 0 , "anchor with href, no tabindex set" ) ;
539+ equals ( jQuery ( "#linkWithTabIndex" ) . prop ( "tabindex" ) , 2 , "anchor with href, tabindex set to 2" ) ;
540+ equals ( jQuery ( "#linkWithNegativeTabIndex" ) . prop ( "tabindex" ) , - 1 , "anchor with href, tabindex set to -1" ) ;
541+
542+ // anchor without href
543+ equals ( jQuery ( "#linkWithNoHrefWithNoTabIndex" ) . prop ( "tabindex" ) , undefined , "anchor without href, no tabindex set" ) ;
544+ equals ( jQuery ( "#linkWithNoHrefWithTabIndex" ) . prop ( "tabindex" ) , 1 , "anchor without href, tabindex set to 2" ) ;
545+ equals ( jQuery ( "#linkWithNoHrefWithNegativeTabIndex" ) . prop ( "tabindex" ) , - 1 , "anchor without href, no tabindex set" ) ;
546+ } ) ;
547+
548+ test ( "prop('tabindex', value)" , function ( ) {
549+ expect ( 9 ) ;
550+
551+ var element = jQuery ( "#divWithNoTabIndex" ) ;
552+ equals ( element . prop ( "tabindex" ) , undefined , "start with no tabindex" ) ;
553+
554+ // set a positive string
555+ element . prop ( "tabindex" , "1" ) ;
556+ equals ( element . prop ( "tabindex" ) , 1 , "set tabindex to 1 (string)" ) ;
557+
558+ // set a zero string
559+ element . prop ( "tabindex" , "0" ) ;
560+ equals ( element . prop ( "tabindex" ) , 0 , "set tabindex to 0 (string)" ) ;
561+
562+ // set a negative string
563+ element . prop ( "tabindex" , "-1" ) ;
564+ equals ( element . prop ( "tabindex" ) , - 1 , "set tabindex to -1 (string)" ) ;
565+
566+ // set a positive number
567+ element . prop ( "tabindex" , 1 ) ;
568+ equals ( element . prop ( "tabindex" ) , 1 , "set tabindex to 1 (number)" ) ;
569+
570+ // set a zero number
571+ element . prop ( "tabindex" , 0 ) ;
572+ equals ( element . prop ( "tabindex" ) , 0 , "set tabindex to 0 (number)" ) ;
573+
574+ // set a negative number
575+ element . prop ( "tabindex" , - 1 ) ;
576+ equals ( element . prop ( "tabindex" ) , - 1 , "set tabindex to -1 (number)" ) ;
577+
578+ element = jQuery ( "#linkWithTabIndex" ) ;
579+ equals ( element . prop ( "tabindex" ) , 2 , "start with tabindex 2" ) ;
580+
581+ element . prop ( "tabindex" , - 1 ) ;
582+ equals ( element . prop ( "tabindex" ) , - 1 , "set negative tabindex" ) ;
583+ } ) ;
584+
530585test ( "removeProp(String)" , function ( ) {
531586 expect ( 6 ) ;
532587 var attributeNode = document . createAttribute ( "irrelevant" ) ,
0 commit comments