diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-09-11 12:51:51 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-11 12:51:51 -0400 |
commit | 88e71f82232781a1bc16701ce4719d770222ec4c (patch) | |
tree | aa2449826f9f71a4b16733521c82f73f6e22618e /ext/js/display/display-generator.js | |
parent | 6661933d4727ef4797eeb945f8c1b0b67f546b9d (diff) |
Add data-is-primary attribute to headwords (#1946)
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 95b4224b..fe899e53 100644 --- a/ext/js/display/display-generator.js +++ b/ext/js/display/display-generator.js @@ -232,12 +232,21 @@ class DisplayGenerator { // Private _createTermHeadword(headword, headwordIndex, pronunciations) { - const {term, reading, tags} = headword; + const {term, reading, tags, sources} = headword; + + let isPrimaryAny = false; + for (const {isPrimary} of sources) { + if (isPrimary) { + isPrimaryAny = true; + break; + } + } const node = this._templates.instantiate('headword'); const termContainer = node.querySelector('.headword-term'); + node.dataset.isPrimary = `${isPrimaryAny}`; node.dataset.readingIsSame = `${reading === term}`; node.dataset.frequency = DictionaryDataUtil.getTermFrequency(tags); |