1
1
/* global document */
2
2
3
- var nodeName = node . nodeName . toUpperCase ( ) ,
4
- nodeType = node . type ;
3
+ const nodeName = node . nodeName . toUpperCase ( ) ;
4
+ const nodeType = node . type ;
5
5
6
6
if (
7
7
node . getAttribute ( 'aria-disabled' ) === 'true' ||
45
45
}
46
46
47
47
// check if the element is a label or label descendant for a disabled control
48
- var nodeParentLabel = axe . commons . dom . findUpVirtual ( virtualNode , 'label' ) ;
48
+ const nodeParentLabel = axe . commons . dom . findUpVirtual ( virtualNode , 'label' ) ;
49
49
if ( nodeName === 'LABEL' || nodeParentLabel ) {
50
- var relevantNode = node ;
51
- var relevantVirtualNode = virtualNode ;
50
+ let relevantNode = node ;
51
+ let relevantVirtualNode = virtualNode ;
52
52
53
53
if ( nodeParentLabel ) {
54
54
relevantNode = nodeParentLabel ;
55
55
// we need an input candidate from a parent to account for label children
56
56
relevantVirtualNode = axe . utils . getNodeFromTree ( nodeParentLabel ) ;
57
57
}
58
58
// explicit label of disabled input
59
- let doc = axe . commons . dom . getRootNode ( relevantNode ) ;
60
- var candidate =
59
+ const doc = axe . commons . dom . getRootNode ( relevantNode ) ;
60
+ let candidate =
61
61
relevantNode . htmlFor && doc . getElementById ( relevantNode . htmlFor ) ;
62
- if ( candidate && candidate . disabled ) {
62
+ const candidateVirtualNode = axe . utils . getNodeFromTree ( candidate ) ;
63
+
64
+ if (
65
+ candidate &&
66
+ ( candidate . disabled ||
67
+ candidate . getAttribute ( 'aria-disabled' ) === 'true' ||
68
+ axe . commons . dom . findUpVirtual (
69
+ candidateVirtualNode ,
70
+ '[aria-disabled="true"]'
71
+ ) )
72
+ ) {
63
73
return false ;
64
74
}
65
75
66
- var candidate = axe . utils . querySelectorAll (
76
+ candidate = axe . utils . querySelectorAll (
67
77
relevantVirtualNode ,
68
78
'input:not([type="hidden"]):not([type="image"])' +
69
79
':not([type="button"]):not([type="submit"]):not([type="reset"]), select, textarea'
@@ -76,8 +86,8 @@ if (nodeName === 'LABEL' || nodeParentLabel) {
76
86
// label of disabled control associated w/ aria-labelledby
77
87
if ( node . getAttribute ( 'id' ) ) {
78
88
const id = axe . utils . escapeSelector ( node . getAttribute ( 'id' ) ) ;
79
- let doc = axe . commons . dom . getRootNode ( node ) ;
80
- var candidate = doc . querySelector ( '[aria-labelledby~=' + id + ']' ) ;
89
+ const doc = axe . commons . dom . getRootNode ( node ) ;
90
+ const candidate = doc . querySelector ( '[aria-labelledby~=' + id + ']' ) ;
81
91
if ( candidate && candidate . disabled ) {
82
92
return false ;
83
93
}
@@ -87,11 +97,11 @@ if (axe.commons.text.visibleVirtual(virtualNode, false, true) === '') {
87
97
return false ;
88
98
}
89
99
90
- var range = document . createRange ( ) ,
91
- childNodes = virtualNode . children ,
92
- length = childNodes . length ,
93
- child ,
94
- index ;
100
+ const range = document . createRange ( ) ;
101
+ const childNodes = virtualNode . children ;
102
+ let length = childNodes . length ;
103
+ let child = null ;
104
+ let index = 0 ;
95
105
96
106
for ( index = 0 ; index < length ; index ++ ) {
97
107
child = childNodes [ index ] ;
@@ -104,7 +114,7 @@ for (index = 0; index < length; index++) {
104
114
}
105
115
}
106
116
107
- var rects = range . getClientRects ( ) ;
117
+ const rects = range . getClientRects ( ) ;
108
118
length = rects . length ;
109
119
110
120
for ( index = 0 ; index < length ; index ++ ) {
0 commit comments