All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.dist.module-debug.sanitize.js Maven / Gradle / Ivy

The newest version!
const escape_div = document.createElement("div"),
      escape_text = document.createTextNode(""),
      sanitizer_div = document.createElement("div");

escape_div.appendChild(escape_text);

/**
 * @param {*} str
 * @return {string}
 */

export function escape(str) {

    if (escape_div._text !== str) {

        escape_text.nodeValue = /** @type {string} */str;
        escape_div._html = escape_div.innerHTML;
        escape_div._text = str;
    }

    return escape_div._html;
}

/**
 * @param {*} str
 * @return {string}
 */

export function sanitize(str) {

    if (sanitizer_div._html !== str) {

        sanitizer_div.innerHTML = str;
        sanitizer_div._html = str;
        sanitizer_div._text = sanitizer_div.textContent;
    }

    return sanitizer_div._text;
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy