Closed Firioesa closed 1 month ago
Heya :slightly_smiling_face: I think this would do the trick, no?
DOMPurify.sanitize("<b>tea</b>", {
ALLOWED_TAGS: ["b", '#text'],
KEEP_CONTENT: false
})
@cure53 Oh it does solve my issue. Thanks!
Hi guys, thanks for creating this library. I've been using it for my projects and it works really well, except for the
KEEP_CONTENT
config. The documentation states:I'd expect that
KEEP_CONTENT
only affects disallowed tags (because they will be removed). However, according to my test, ifKEEP_CONTENT
isfalse
, all content within the allowed tags is removed, while the tags remain.Example:
Output:
<b></b>
Expected:<b>tea</b>
So, how do I keep the all (tags and content) of the allowed tags while removing all of other tags?
I'm using the latest version.