const sanitizer = new Sanitizer();Sanitizer / notebook
Sanitizer
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const sanitizer = new Sanitizer({});
console.log(sanitizer.get());
/*
{
"comments": true,
"removeAttributes": [],
"removeElements": []
}
*/const sanitizer = new Sanitizer({ elements: ["div", "p", "script"] });
sanitizer.allowElement("span");
sanitizer.allowAttribute("id");
sanitizer.replaceElementWithChildren("b");
sanitizer.setComments(true);const sanitizer = new Sanitizer({ removeElements: ["span", "script"] });
sanitizer.removeElement("h6");
sanitizer.removeAttribute("lang");
sanitizer.setComments(false);