MCPcopy
hub / github.com/textAngular/textAngular / decodeEntities

Function decodeEntities

src/textAngular-sanitize.js:438–457  ·  view source on GitHub ↗

* decodes all entities into regular string * @param value * @returns {string} A string with decoded entities.

(value)

Source from the content-addressed store, hash-verified

436 * @returns {string} A string with decoded entities.
437 */
438function decodeEntities(value) {
439 if (!value) { return ''; }
440
441 // Note: IE8 does not preserve spaces at the start/end of innerHTML
442 // so we must capture them and reattach them afterward
443 var parts = spaceRe.exec(value);
444 var spaceBefore = parts[1];
445 var spaceAfter = parts[3];
446 var content = parts[2];
447 if (content) {
448 hiddenPre.innerHTML=content.replace(/</g,"&lt;");
449 // innerText depends on styling as it doesn't display hidden elements.
450 // Therefore, it's better to use textContent not to cause unnecessary
451 // reflows. However, IE<9 don't support textContent so the innerText
452 // fallback is necessary.
453 content = 'textContent' in hiddenPre ?
454 hiddenPre.textContent : hiddenPre.innerText;
455 }
456 return spaceBefore + content + spaceAfter;
457}
458
459/**
460 * Escapes all potentially dangerous characters, so that the

Callers 2

htmlParserFunction · 0.85
parseStartTagFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected