diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-02-16 21:19:52 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-16 21:19:52 -0500 |
commit | 53d02ca3d36eade7e0e6432b348f96a4c1f7b359 (patch) | |
tree | 28f0ef8bc5bc4acaedba1b3feeba3992b473064e /ext/js/display/display-generator.js | |
parent | 6fc5eb2ae1f367a5409ecf8b961e2987ee069ee9 (diff) |
Fix search tags in split and grouped display modes (#1412)
Diffstat (limited to 'ext/js/display/display-generator.js')
-rw-r--r-- | ext/js/display/display-generator.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/ext/js/display/display-generator.js b/ext/js/display/display-generator.js index 1b3908fe..d02e2d9c 100644 --- a/ext/js/display/display-generator.js +++ b/ext/js/display/display-generator.js @@ -70,7 +70,8 @@ class DisplayGenerator { const uniqueExpressions = new Set(); const uniqueReadings = new Set(); - for (const {expression, reading} of expressions) { + for (let {expression, reading} of expressions) { + if (reading.length === 0) { reading = expression; } uniqueExpressions.add(expression); uniqueReadings.add(reading); } @@ -92,6 +93,14 @@ class DisplayGenerator { this._appendMultiple(pitchesContainer, this._createPitches.bind(this), pitches); this._appendMultiple(termTagsContainer, this._createTermTag.bind(this), termTags, expressions.length); + for (const expression of uniqueExpressions) { + termTagsContainer.appendChild(this._createSearchTag(expression)); + } + for (const reading of uniqueReadings) { + if (uniqueExpressions.has(reading)) { continue; } + termTagsContainer.appendChild(this._createSearchTag(reading)); + } + // Add definitions const dictionaryTag = this._createDictionaryTag(null); for (let i = 0, ii = definitions.length; i < ii; ++i) { |