Skip to content

Commit cec8833

Browse files
committed
fixed: using variable before declaration...
not sure if this can cause the variable `target` to go global.
1 parent 5dffbf2 commit cec8833

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Diff for: src/helpers/scopeTab.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export default function scopeTab(node, event) {
99
return;
1010
}
1111

12+
let target;
13+
1214
const shiftKey = event.shiftKey;
1315
const head = tabbable[0];
1416
const tail = tabbable[tabbable.length - 1];
@@ -20,7 +22,6 @@ export default function scopeTab(node, event) {
2022
target = tail;
2123
}
2224

23-
var target;
2425
if (tail === document.activeElement && !shiftKey) {
2526
target = head;
2627
}
@@ -62,9 +63,11 @@ export default function scopeTab(node, event) {
6263
x += shiftKey ? -1 : 1;
6364
}
6465

66+
target = tabbable[x];
67+
6568
// If the tabbable element does not exist,
6669
// focus head/tail based on shiftKey
67-
if (typeof tabbable[x] === "undefined") {
70+
if (typeof target === "undefined") {
6871
event.preventDefault();
6972
target = shiftKey ? tail : head;
7073
target.focus();
@@ -73,5 +76,5 @@ export default function scopeTab(node, event) {
7376

7477
event.preventDefault();
7578

76-
tabbable[x].focus();
79+
target.focus();
7780
}

0 commit comments

Comments
 (0)