0.1.0 • Published 2 years ago

@intrnl/dom-sanitize v0.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

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;