-
-
Save bevacqua/83d98737ffd3b5509212 to your computer and use it in GitHub Desktop.
he browser shim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function encodeHtml (text) { | |
if (!text) { | |
return text; | |
} | |
var div = document.createElement('div'); | |
div.innerText = div.textContent = text; | |
return div.innerHTML; | |
} | |
function decodeHtml (html) { | |
if (!html) { | |
return html; | |
} | |
var div = document.createElement('div'); | |
div.innerHTML = html; | |
return div.innerText || div.textContent; | |
} | |
encodeHtml.options = decodeHtml.options = {}; | |
module.exports = { | |
encode: encodeHtml, | |
escape: encodeHtml, | |
decode: decodeHtml, | |
unescape: decodeHtml, | |
version: '1.0.0-browser' | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See mathiasbynens/he#24.