Created
August 4, 2020 11:13
-
-
Save BlaM/5191ad05920b367dcd216a9d7cf66ee5 to your computer and use it in GitHub Desktop.
escape-html.js
This file contains hidden or 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 escapeHtml(str) { | |
escapeHtml.tmp.innerText = str; | |
var res = escapeHtml.tmp.innerHTML.replace(escapeHtml.quot, '"').replace(escapeHtml.apos, '''); | |
return res; | |
} | |
escapeHtml.tmp = document.createElement('span'); | |
escapeHtml.quot = /"/g; | |
escapeHtml.apos = /'/g; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment