@intrnl/dom-sanitize
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

dom-sanitize

Lightweight DOM sanitization library

import { DEFAULT_OPTIONS, sanitize } from '@intrnl/dom-sanitize';

const result = sanitize(`<img src=x onerror=alert(1)//>`, DEFAULT_OPTIONS);

// `result` returns a DocumentFragment, you can convert this by creating a template element
const template = document.createElement('template');

// Append document fragment to another, this empties out `result`
template.content.appendChild(result);

// `<img src="x">`
template.innerHTML;

/@intrnl/dom-sanitize/

    Package Sidebar

    Install

    npm i @intrnl/dom-sanitize

    Weekly Downloads

    0

    Version

    0.1.0

    License

    MIT

    Unpacked Size

    30.3 kB

    Total Files

    7

    Last publish

    Collaborators

    • intrnl