From 16217728afe0f9ff7dcbb7c7b7ead454ccc8705f Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 6 Mar 2021 15:53:45 -0500 Subject: Improve empty reading handling (#1497) * Handle empty readings earlier in the definition creation process * Remove empty reading check * Remove special handling of empty readings --- ext/js/display/display-generator.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'ext/js/display') diff --git a/ext/js/display/display-generator.js b/ext/js/display/display-generator.js index 93e84bdd..d8ae566e 100644 --- a/ext/js/display/display-generator.js +++ b/ext/js/display/display-generator.js @@ -70,8 +70,7 @@ class DisplayGenerator { const uniqueExpressions = new Set(); const uniqueReadings = new Set(); - for (let {expression, reading} of expressions) { - if (reading.length === 0) { reading = expression; } + for (const {expression, reading} of expressions) { uniqueExpressions.add(expression); uniqueReadings.add(reading); } @@ -244,7 +243,7 @@ class DisplayGenerator { const expressionContainer = node.querySelector('.expression-text'); const tagContainer = node.querySelector('.expression-tag-list'); - node.dataset.readingIsSame = `${!reading || reading === expression}`; + node.dataset.readingIsSame = `${reading === expression}`; node.dataset.frequency = termFrequency; const pitchAccentCategories = this._getPitchAccentCategories(pitches); @@ -252,7 +251,7 @@ class DisplayGenerator { node.dataset.pitchAccentCategories = pitchAccentCategories; } - this._setTextContent(node.querySelector('.expression-reading'), reading.length > 0 ? reading : expression); + this._setTextContent(node.querySelector('.expression-reading'), reading); this._appendFurigana(expressionContainer, furiganaSegments, this._appendKanjiLinks.bind(this)); this._appendMultiple(tagContainer, this._createTag.bind(this), termTags); -- cgit v1.2.3