From 332f95e1ffbac0c392d18bdf878502af5403606a Mon Sep 17 00:00:00 2001 From: Jeremy Schomery Date: Wed, 19 Jul 2017 15:13:24 +0300 Subject: [PATCH] i18n-html to i18n-text if possible. tNodeList now parses HTML content using tHTML --- edit.html | 2 +- js/localization.js | 6 +++++- manage.html | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/edit.html b/edit.html index 5df54d54..4684b534 100644 --- a/edit.html +++ b/edit.html @@ -61,7 +61,7 @@ diff --git a/js/localization.js b/js/localization.js index 20c0be7d..d976ab62 100644 --- a/js/localization.js +++ b/js/localization.js @@ -96,7 +96,11 @@ function tNodeList(nodes) { node.appendChild(document.createTextNode(value)); break; 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; default: node.setAttribute(type, value); diff --git a/manage.html b/manage.html index b3bb0545..1a5cae15 100644 --- a/manage.html +++ b/manage.html @@ -117,7 +117,7 @@