mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2026-01-05 06:54:36 +08:00
refactor: update based on logical value, not DOM class
This commit is contained in:
parent
9eb927b2f4
commit
c3274f0f02
1 changed files with 8 additions and 7 deletions
|
|
@ -779,9 +779,6 @@ export async function updateActiveWordLetters(
|
|||
inputOverride?: string
|
||||
): Promise<void> {
|
||||
const input = inputOverride ?? TestInput.input.current;
|
||||
const wordAtIndex = document.querySelector(
|
||||
"#words .word.active"
|
||||
) as HTMLElement;
|
||||
const currentWord = TestWords.words.getCurrent();
|
||||
if (!currentWord && Config.mode !== "zen") return;
|
||||
let ret = "";
|
||||
|
|
@ -915,13 +912,17 @@ export async function updateActiveWordLetters(
|
|||
}
|
||||
}
|
||||
|
||||
wordAtIndex.innerHTML = ret;
|
||||
const activeWord = document.querySelectorAll("#words .word")?.[
|
||||
activeWordElementIndex
|
||||
] as HTMLElement;
|
||||
|
||||
activeWord.innerHTML = ret;
|
||||
|
||||
if (hintIndices?.length) {
|
||||
const activeWordLetters = wordAtIndex.querySelectorAll("letter");
|
||||
const activeWordLetters = activeWord.querySelectorAll("letter");
|
||||
const hintsHtml = createHintsHtml(hintIndices, activeWordLetters, input);
|
||||
wordAtIndex.insertAdjacentHTML("beforeend", hintsHtml);
|
||||
const hintElements = wordAtIndex.getElementsByTagName("hint");
|
||||
activeWord.insertAdjacentHTML("beforeend", hintsHtml);
|
||||
const hintElements = activeWord.getElementsByTagName("hint");
|
||||
await joinOverlappingHints(hintIndices, activeWordLetters, hintElements);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue