diff --git a/modules/xerte/parent_templates/Nottingham/common_html5/js/xenith.js b/modules/xerte/parent_templates/Nottingham/common_html5/js/xenith.js index 9f5ff4f18..e14b80568 100644 --- a/modules/xerte/parent_templates/Nottingham/common_html5/js/xenith.js +++ b/modules/xerte/parent_templates/Nottingham/common_html5/js/xenith.js @@ -4527,9 +4527,15 @@ var XENITH = (function ($, parent) { var self = parent.GLOSSARY = {}; return found && !multiple_terms; }); } + // Need to treat single text node differently but rebuild from fragmant OLD WAY + //let arr = Array.prototype.slice.call(fragment.childNodes); + //tempText = arr.length === 1 && nodes.length > 0 ? nodes[0].textContent : [].map.call(fragment.childNodes, x => x.nodeType === x.TEXT_NODE ? x.textContent : x.outerHTML).join(''); - // Need to treat single text node differently but rebuild from fragmant - tempText = Array.from(fragment.childNodes).length === 1 && nodes.length > 0 ? nodes[0].textContent : Array.from(fragment.childNodes).map(function(x) {return x.outerHTML || x.textContent;}).join(''); + // Instead we'll just let the DOM do the heavy lifting + let div = document.createElement("div"); + div.appendChild(fragment); + tempText = div.innerHTML; + div.remove(); // Replace all our tokens with the glossary tag for (var k=0, len=x_glossary.length; k