Remove getElementIndex

This commit is contained in:
Leonabcd123 2026-01-07 20:58:47 +02:00
parent 5c5d6af536
commit db0e29cdf4
2 changed files with 5 additions and 16 deletions

View file

@ -314,14 +314,14 @@ qs("#replayWords")?.onChild("click", "letter", (event) => {
pauseReplay();
const replayWords = qs("#replayWords");
const words = replayWords?.getChildren();
const words = [...(replayWords?.native?.children ?? [])];
targetWordPos =
words?.getElementIndex(
words?.indexOf(
(event.childTarget as HTMLElement).parentNode as HTMLElement,
) ?? 0;
const letters = words?.[targetWordPos]?.getChildren();
targetCurPos =
letters?.getElementIndex(event.childTarget as HTMLElement) ?? 0;
const letters = [...(words[targetWordPos] as HTMLElement).children];
targetCurPos = letters?.indexOf(event.childTarget as HTMLElement) ?? 0;
initializeReplayPrompt();
loadOldReplay();

View file

@ -862,17 +862,6 @@ export class ElementsWithUtils<
return this;
}
/**
* Get the index of element in the array
*/
getElementIndex(element: HTMLElement): number {
console.warn(this.length);
for (let i = 0; i < this.length; i++) {
if (this[i]?.native === element) return i;
}
return -1;
}
/**
* Set multiple style properties on all elements in the array.
* An empty object clears all styles.