From 434d098b4f753c982581f7915d34e7c6a0ce4b77 Mon Sep 17 00:00:00 2001 From: dima-safin-2025 Date: Fri, 9 Aug 2024 17:01:52 +0800 Subject: [PATCH] refactor: move 'li' variable declaration outside of switch cases --- book/book/book.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/book/book/book.js b/book/book/book.js index aa12e7e..0737a08 100644 --- a/book/book/book.js +++ b/book/book/book.js @@ -408,7 +408,7 @@ 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(); @@ -416,14 +416,12 @@ function playground_text(playground, hidden = true) { 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(); }