Skip to content
This repository has been archived by the owner on Feb 25, 2023. It is now read-only.

Fix incorrect selector causing invalid headword index to be used #1705

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ext/js/display/display-audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ class DisplayAudio {
}

_getAudioPlayButtonHeadwordIndex(button) {
const headwordNode = button.closest('.expression');
const headwordNode = button.closest('.headword');
if (headwordNode !== null) {
const headwordIndex = parseInt(headwordNode.dataset.index, 10);
if (Number.isFinite(headwordIndex)) { return headwordIndex; }
Expand All @@ -297,7 +297,7 @@ class DisplayAudio {
if (dictionaryEntryIndex >= 0 && dictionaryEntryIndex < dictionaryEntryNodes.length) {
const node = dictionaryEntryNodes[dictionaryEntryIndex];
const button1 = (headwordIndex === 0 ? node.querySelector('.action-play-audio') : null);
const button2 = node.querySelector(`.expression:nth-of-type(${headwordIndex + 1}) .action-play-audio`);
const button2 = node.querySelector(`.headword:nth-of-type(${headwordIndex + 1}) .action-play-audio`);
if (button1 !== null) { results.push(button1); }
if (button2 !== null) { results.push(button2); }
}
Expand Down