Skip to content

DOMPurifyI.sanitize method

DOMPurifyI › sanitize

Unofficial

Sanitize a string or DOM node.

Signature:

sanitize(source: string | Node): string

Parameters:

ParameterTypeDescription
sourcestring | NodeThe input to sanitize.

Returns: stringThe sanitized string.


Unofficial

Sanitize a string or DOM node and return a DocumentFragment.

Signature:

sanitize(source: string | Node, config: Config & ConfigReturnDomFragment): DocumentFragment

Parameters:

ParameterTypeDescription
sourcestring | NodeThe input to sanitize.
configConfig & ConfigReturnDomFragmentConfiguration with RETURN_DOM_FRAGMENT enabled.

Returns: DocumentFragmentThe sanitized DocumentFragment.


Unofficial

Sanitize a string or DOM node and return an HTMLElement.

Signature:

sanitize(source: string | Node, config: Config & ConfigReturnDom): HTMLElement

Parameters:

ParameterTypeDescription
sourcestring | NodeThe input to sanitize.
configConfig & ConfigReturnDomConfiguration with RETURN_DOM enabled.

Returns: HTMLElementThe sanitized HTMLElement.


Unofficial

Sanitize a string or DOM node with custom configuration.

Signature:

sanitize(source: string | Node, config: Config): string

Parameters:

ParameterTypeDescription
sourcestring | NodeThe input to sanitize.
configConfigThe sanitization configuration.

Returns: stringThe sanitized string.