1.0.21 ⢠Published 9 months ago
universal-dompurify v1.0.21
universal-dompurify
š Use DOMPurify for some context by conditional exports
Installation
npm i universal-dompurify
Usage
Conditional exports apply the appropriate DOMPurify file at each run.
import DOMPurify from 'universal-dompurify'
const cleaned = DOMPurify.sanitize(/* ... */)
condition | resolve |
---|---|
browser | DOMPurify |
default | DOMPurify + JSDOM |
worker | DOMPurify + JSDOM + (require: your external node polyfills) |
!TIP It is generally not recommended to use JSDOM with the restricted Edge runtime.
See also @jill64/universal-sanitizer for a more lightweight alternative.
Browser Only Mode
Reduces bundle size by omitting rendering on the server.
/** @type {DOMPurify | null} */
import DOMPurify from 'universal-dompurify/browser-only'
const cleaned = DOMPurify?.sanitize?.(/* ... */) ?? 'server-fallback-value'
condition | resolve |
---|---|
browser | DOMPurify |
default | null |
worker | null |
License
1.0.21
9 months ago
1.0.20
9 months ago
1.0.19
10 months ago
1.0.18
10 months ago
1.0.17
10 months ago
1.0.16
11 months ago
1.0.15
12 months ago
1.0.14
1 year ago
1.0.13
1 year ago
1.0.12
1 year ago
1.0.11
1 year ago
1.0.10
1 year ago
1.0.9
1 year ago
1.0.8
1 year ago
1.0.7
1 year ago
1.0.6
1 year ago
1.0.5
1 year ago
1.0.4
1 year ago
1.0.3
1 year ago
1.0.2
1 year ago
1.0.1
1 year ago
1.0.0
2 years ago
0.4.1
2 years ago
0.4.0
2 years ago
0.3.0
2 years ago
0.2.0
2 years ago
0.1.1
2 years ago
0.1.0
2 years ago
0.0.1
2 years ago