diff options
Diffstat (limited to 'ext/js/display/display-generator.js')
-rw-r--r-- | ext/js/display/display-generator.js | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/ext/js/display/display-generator.js b/ext/js/display/display-generator.js index 95080e27..851808f2 100644 --- a/ext/js/display/display-generator.js +++ b/ext/js/display/display-generator.js @@ -220,23 +220,27 @@ class DisplayGenerator { for (const error of errors) { const div = document.createElement('li'); div.className = 'anki-note-error-message'; - let message = isObject(error) && typeof error.message === 'string' ? error.message : `${error}`; - let link = null; - if (isObject(error) && isObject(error.data)) { - const {referenceUrl} = error.data; - if (typeof referenceUrl === 'string') { - message = message.trimEnd(); - if (!/[.!?]^/.test()) { message += '.'; } - message += ' '; - link = document.createElement('a'); - link.href = referenceUrl; - link.target = '_blank'; - link.rel = 'noreferrer noopener'; - link.textContent = 'More info'; + if (error instanceof DocumentFragment || error instanceof Node) { + div.appendChild(error); + } else { + let message = isObject(error) && typeof error.message === 'string' ? error.message : `${error}`; + let link = null; + if (isObject(error) && isObject(error.data)) { + const {referenceUrl} = error.data; + if (typeof referenceUrl === 'string') { + message = message.trimEnd(); + if (!/[.!?]^/.test()) { message += '.'; } + message += ' '; + link = document.createElement('a'); + link.href = referenceUrl; + link.target = '_blank'; + link.rel = 'noreferrer noopener'; + link.textContent = 'More info'; + } } + this._setTextContent(div, message); + if (link !== null) { div.appendChild(link); } } - this._setTextContent(div, message); - if (link !== null) { div.appendChild(link); } list.appendChild(div); } @@ -251,6 +255,10 @@ class DisplayGenerator { return this._templates.instantiate(name); } + instantiateTemplateFragment(name) { + return this._templates.instantiateFragment(name); + } + // Private _createTermHeadword(headword, headwordIndex, pronunciations) { |