File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change 1
- return node . tabIndex <= 0 ;
1
+ const tabIndex = parseInt ( node . getAttribute ( 'tabindex' ) , 10 ) ;
2
+
3
+ // an invalid tabindex will either return 0 or -1 (based on the element) so
4
+ // will never be above 0
5
+ // @see https://www.w3.org/TR/html51/editing.html#the-tabindex-attribute
6
+ return isNaN ( tabIndex ) ? true : tabIndex <= 0 ;
Original file line number Diff line number Diff line change @@ -22,4 +22,21 @@ describe('tabindex', function() {
22
22
23
23
assert . isTrue ( checks . tabindex . evaluate ( node ) ) ;
24
24
} ) ;
25
+
26
+ it ( 'should look at the attribute and not the property' , function ( ) {
27
+ var node = document . createElement ( 'div' ) ;
28
+ node . setAttribute ( 'tabindex' , '1' ) ;
29
+ node . tabindex = null ;
30
+ fixture . appendChild ( node ) ;
31
+
32
+ assert . isFalse ( checks . tabindex . evaluate ( node ) ) ;
33
+ } ) ;
34
+
35
+ it ( 'should pass if tabindex is NaN' , function ( ) {
36
+ var node = document . createElement ( 'div' ) ;
37
+ node . setAttribute ( 'tabindex' , 'foobar' ) ;
38
+ fixture . appendChild ( node ) ;
39
+
40
+ assert . isTrue ( checks . tabindex . evaluate ( node ) ) ;
41
+ } ) ;
25
42
} ) ;
You can’t perform that action at this time.
0 commit comments