diff options
Diffstat (limited to 'ext/js/display')
-rw-r--r-- | ext/js/display/display-audio.js | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/ext/js/display/display-audio.js b/ext/js/display/display-audio.js index 6d2504e4..e5c1b135 100644 --- a/ext/js/display/display-audio.js +++ b/ext/js/display/display-audio.js @@ -352,6 +352,7 @@ class DisplayAudio { const headword = this._getHeadword(dictionaryEntryIndex, headwordIndex); if (headword === null) { return; } + const {index} = source; const {term, reading} = headword; const cacheEntry = this._getCacheItem(term, reading, true); @@ -359,9 +360,9 @@ class DisplayAudio { primaryCardAudio = ( !canToggleOff || primaryCardAudio === null || - primaryCardAudio.source !== source || - primaryCardAudio.index !== subIndex - ) ? {index: source.index, subIndex} : null; + primaryCardAudio.index !== index || + primaryCardAudio.subIndex !== subIndex + ) ? {index: index, subIndex} : null; cacheEntry.primaryCardAudio = primaryCardAudio; if (menu !== null) { @@ -698,8 +699,9 @@ class DisplayAudio { const primaryCardAudioSubIndex = (primaryCardAudio !== null ? primaryCardAudio.subIndex : null); const itemGroups = menuBodyNode.querySelectorAll('.popup-menu-item-group'); for (const node of itemGroups) { - const index = Number.parseInt(node.dataset.index, 10); - const subIndex = Number.parseInt(node.dataset.subIndex, 10); + let {index, subIndex} = node.dataset; + index = Number.parseInt(index, 10); + subIndex = typeof subIndex === 'string' ? Number.parseInt(subIndex, 10) : null; const isPrimaryCardAudio = (index === primaryCardAudioIndex && subIndex === primaryCardAudioSubIndex); node.dataset.isPrimaryCardAudio = `${isPrimaryCardAudio}`; } |