/// import dompurify = require('dompurify'); dompurify.sanitize(''); dompurify.addHook('beforeSanitizeElements', (el, data, config) => { return el; }); //examples from the DOMPurify README let dirty = '

Totally safe

Totally not safe

'; // allow only dompurify.sanitize(dirty, {ALLOWED_TAGS: ['b']}); // allow only and with style attributes (for whatever reason) dompurify.sanitize(dirty, {ALLOWED_TAGS: ['b', 'q'], ALLOWED_ATTR: ['style']}); // leave all as it is but forbid