aboutsummaryrefslogtreecommitdiff
path: root/ext/mixed/js/display-generator.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-01-28 19:06:50 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-02-01 21:00:27 -0500
commit6b9116ee498b562202da8c69d983c0e7bf45e15b (patch)
tree3f07947d0690594850fc09883e83aeadb870d7a6 /ext/mixed/js/display-generator.js
parent1d9332cb69d76818a1f6a422ceafc3a463c48d7c (diff)
Fix term tags not always being displayed
Diffstat (limited to 'ext/mixed/js/display-generator.js')
-rw-r--r--ext/mixed/js/display-generator.js14
1 files changed, 11 insertions, 3 deletions
diff --git a/ext/mixed/js/display-generator.js b/ext/mixed/js/display-generator.js
index 0a57df80..b2dc373b 100644
--- a/ext/mixed/js/display-generator.js
+++ b/ext/mixed/js/display-generator.js
@@ -71,7 +71,11 @@ class DisplayGenerator {
node.dataset.expressionCount = `${expressionMulti ? details.expressions.length : 1}`;
node.dataset.definitionCount = `${definitionMulti ? details.definitions.length : 1}`;
- DisplayGenerator._appendMultiple(expressionsContainer, this.createTermExpression.bind(this), details.expressions, [details]);
+ const termTags = details.termTags;
+ let expressions = details.expressions;
+ expressions = Array.isArray(expressions) ? expressions.map((e) => [e, termTags]) : null;
+
+ DisplayGenerator._appendMultiple(expressionsContainer, this.createTermExpression.bind(this), expressions, [[details, termTags]]);
DisplayGenerator._appendMultiple(reasonsContainer, this.createTermReason.bind(this), details.reasons);
DisplayGenerator._appendMultiple(frequenciesContainer, this.createFrequencyTag.bind(this), details.frequencies);
DisplayGenerator._appendMultiple(definitionsContainer, this.createTermDefinitionItem.bind(this), details.definitions, [details]);
@@ -83,7 +87,7 @@ class DisplayGenerator {
return node;
}
- createTermExpression(details) {
+ createTermExpression([details, termTags]) {
const node = DisplayGenerator._instantiateTemplate(this._termExpressionTemplate);
const expressionContainer = node.querySelector('.term-expression-text');
@@ -103,7 +107,11 @@ class DisplayGenerator {
DisplayGenerator._appendFurigana(expressionContainer, furiganaSegments, this._appendKanjiLinks.bind(this));
}
- DisplayGenerator._appendMultiple(tagContainer, this.createTag.bind(this), details.termTags);
+ if (!Array.isArray(termTags)) {
+ // Fallback
+ termTags = details.termTags;
+ }
+ DisplayGenerator._appendMultiple(tagContainer, this.createTag.bind(this), termTags);
DisplayGenerator._appendMultiple(frequencyContainer, this.createFrequencyTag.bind(this), details.frequencies);
return node;