Sanitizer: setComments() method
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The setComments() method of the Sanitizer interface sets whether comments will be allowed or removed by the sanitizer.
The method sets the comments property in this sanitizer's configuration.
Syntax
js
setComments(allow);
Parameters
allow-
trueif comments are allowed, andfalseif they are to be removed.
Return value
None (undefined).
Examples
>How to sanitize comments
The code below shows the basic usage of the setComments() method.
js
// Create sanitizer (in this case the default)
const sanitizer = new Sanitizer();
// Allow comments
sanitizer.setComments(true);
// Remove comments
sanitizer.setComments(false);
Specifications
| Specification |
|---|
| HTML Sanitizer API> # dom-sanitizer-setcomments> |
Browser compatibility
Loading…