@@ -31,7 +31,7 @@ interface InertHTMLElement extends HTMLElement {
31
31
}
32
32
33
33
/**
34
- Compiles a list of nodes that can be focused. Walkes the tree, discardes hidden elements and a few edge cases. To calculate the right.
34
+ Compiles a list of nodes that can be focused. Walks the tree, discards hidden elements and a few edge cases. To calculate the right.
35
35
@private
36
36
@param {Element } root the root element to start traversing on
37
37
@returns {Array } list of focusable nodes
@@ -43,7 +43,7 @@ function compileFocusAreas(root: Element = document.body) {
43
43
throw new Error ( 'Element must be in the DOM' ) ;
44
44
}
45
45
46
- let activeElment = getActiveElement ( ownerDocument ) ;
46
+ let activeElement = getActiveElement ( ownerDocument ) ;
47
47
let treeWalker = ownerDocument . createTreeWalker (
48
48
root ,
49
49
NodeFilter . SHOW_ELEMENT ,
@@ -76,13 +76,13 @@ function compileFocusAreas(root: Element = document.body) {
76
76
}
77
77
78
78
// Always accept the 'activeElement' of the document, as it might fail the next check, elements with tabindex="-1"
79
- // can be focused programtically , we'll therefor ensure the current active element is in the list.
80
- if ( node === activeElment ) {
79
+ // can be focused programmatically , we'll therefor ensure the current active element is in the list.
80
+ if ( node === activeElement ) {
81
81
return NodeFilter . FILTER_ACCEPT ;
82
82
}
83
83
84
84
// UA parses the tabindex attribute and applies its default values, If the tabIndex is non negative, the UA can
85
- // foucs it.
85
+ // focus it.
86
86
return node . tabIndex >= 0
87
87
? NodeFilter . FILTER_ACCEPT
88
88
: NodeFilter . FILTER_SKIP ;
@@ -173,14 +173,12 @@ function findNextResponders(root: Element, activeElement: HTMLElement) {
173
173
</caption>
174
174
tab({ backwards: true });
175
175
*/
176
- export default function triggerTab ( options ?: {
177
- backwards : boolean ;
178
- unRestrainTabIndex : boolean ;
179
- } ) : Promise < void > {
176
+ export default function triggerTab ( {
177
+ backwards = false ,
178
+ unRestrainTabIndex = false ,
179
+ } = { } ) : Promise < void > {
180
180
return Promise . resolve ( )
181
181
. then ( ( ) => {
182
- let backwards = ( options && options . backwards ) || false ;
183
- let unRestrainTabIndex = ( options && options . unRestrainTabIndex ) || false ;
184
182
return triggerResponderChange ( backwards , unRestrainTabIndex ) ;
185
183
} )
186
184
. then ( ( ) => {
@@ -190,7 +188,7 @@ export default function triggerTab(options?: {
190
188
191
189
/**
192
190
@private
193
- @param {boolean } backwards when `true` it selects the previous foucs area
191
+ @param {boolean } backwards when `true` it selects the previous focus area
194
192
@param {boolean } unRestrainTabIndex when `true`, will not throw an error if tabindex > 0 is encountered
195
193
@returns {Promise<void> } resolves when all events are fired
196
194
*/
0 commit comments