Skip to content

Commit

Permalink
refactor: move 'li' variable declaration outside of switch cases
Browse files Browse the repository at this point in the history
  • Loading branch information
dima-safin-2025 committed Aug 9, 2024
1 parent a06247e commit 434d098
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions book/book/book.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,22 +408,20 @@ function playground_text(playground, hidden = true) {
document.addEventListener('keydown', function (e) {
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) { return; }
if (!themePopup.contains(e.target)) { return; }

var li = document.activeElement.parentElement;
switch (e.key) {
case 'Escape':
e.preventDefault();
hideThemes();
break;
case 'ArrowUp':
e.preventDefault();
var li = document.activeElement.parentElement;
if (li && li.previousElementSibling) {
li.previousElementSibling.querySelector('button').focus();
}
break;
case 'ArrowDown':
e.preventDefault();
var li = document.activeElement.parentElement;
if (li && li.nextElementSibling) {
li.nextElementSibling.querySelector('button').focus();
}
Expand Down

0 comments on commit 434d098

Please sign in to comment.