Commit d3b34ba
Austin Wood
[fixed] check if focusLaterElements is empty before popping
Without a check to see if the focusLaterElements array is empty, we
end up calling `pop()` on an empty array—resulting in an undefined
value—and inadvertently jump to the `catch` block when we attempt to
call `focus()` on `undefined`.
This ensures that if there are no existing elements to return focus to
once our modal is closed (this happens often in a testing env), we do
not throw a TypeError by accident.1 parent 33e1fe1 commit d3b34ba
1 file changed
+4
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
41 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
42 | 44 | | |
43 | 45 | | |
44 | 46 | | |
| |||
0 commit comments