prototype-3x5/helpers.js

10 lines
249 B
JavaScript
Raw Normal View History

const escapeDiv = document.createElement("div");
/**
* @param {string} text Potentially dangerous text
* @returns {string} Text safe to embed in HTML
**/
function escapeHtml(text) {
escapeDiv.textContent = text;
return escapeDiv.innerHTML;
}