* decodes all entities into regular string * @param value * @returns {string} A string with decoded entities.
(value)
| 436 | * @returns {string} A string with decoded entities. |
| 437 | */ |
| 438 | function 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,"<"); |
| 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 |
no outgoing calls
no test coverage detected