i18n-html to i18n-text if possible. tNodeList now parses HTML content using tHTML

This commit is contained in:
Jeremy Schomery 2017-07-19 15:13:24 +03:00 committed by tophf
parent 0955fc852c
commit 332f95e1ff
3 changed files with 7 additions and 3 deletions

View File

@ -61,7 +61,7 @@
</li> </li>
</template> </template>
<template data-id="appliesToEverything"> <template data-id="appliesToEverything">
<li class="applies-to-everything" i18n-html="appliesToEverything"> <li class="applies-to-everything" i18n-text="appliesToEverything">
<button class="add-applies-to" i18n-text="appliesSpecify"></button> <button class="add-applies-to" i18n-text="appliesSpecify"></button>
</li> </li>
</template> </template>

View File

@ -96,7 +96,11 @@ function tNodeList(nodes) {
node.appendChild(document.createTextNode(value)); node.appendChild(document.createTextNode(value));
break; break;
case 'html': case 'html':
node.insertAdjacentHTML('afterbegin', value); // localized strings only allow having text nodes and links
node.textContent = '';
[...tHTML(value, 'div').childNodes]
.filter(a => a.nodeType === a.TEXT_NODE || a.tagName === 'A')
.forEach(n => node.appendChild(n));
break; break;
default: default:
node.setAttribute(type, value); node.setAttribute(type, value);

View File

@ -117,7 +117,7 @@
<template data-id="extraAppliesTo"> <template data-id="extraAppliesTo">
<details class="applies-to-extra"> <details class="applies-to-extra">
<summary i18n-html="appliesDisplayTruncatedSuffix"></summary> <summary i18n-text="appliesDisplayTruncatedSuffix"></summary>
</details> </details>
</template> </template>