(text)
| 12814 | nbsp: '\u00A0' |
| 12815 | }; |
| 12816 | function decodeEntities(text){ |
| 12817 | return text.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g, function(_, code){ |
| 12818 | if (code[0] === '#') { |
| 12819 | const isHex = code[1] === 'x' || code[1] === 'X'; |
| 12820 | const num = parseInt(code.slice(isHex ? 2 : 1), isHex ? 16 : 10); |
| 12821 | if (!isNaN(num)) { |
| 12822 | try { return String.fromCodePoint(num); } catch(e) {} |
| 12823 | } |
| 12824 | return '&' + code + ';'; |
| 12825 | } |
| 12826 | const key = code.toLowerCase(); |
| 12827 | return (key in HTML_ENTITIES) ? HTML_ENTITIES[key] : '&' + code + ';'; |
| 12828 | }); |
| 12829 | } |
| 12830 | function parseHTMLToFragment(html, fragment, doc){ |
| 12831 | const stack = [fragment]; |
| 12832 | const tokenRe = /<!--[\s\S]*?-->|<!doctype[^>]*>|<\/?[a-zA-Z][^>]*>|[^<]+/gi; |
no outgoing calls
no test coverage detected