prototype-3x5/src/helpers.ts

10 lines
249 B
TypeScript
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;
}