-
Notifications
You must be signed in to change notification settings - Fork 356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discard inner text of tag containing custom data attribute #689
Labels
Comments
You should be able to do this with the existing |
I meant something more like this: If it encounters a custom data attribute: const html = "<div data-keep>...sadgasg<div>ABCDEF</div></div>";
Should produce:
"<div data-keep>...sadgasg<div></div></div>" or maybe even "<div>...sadgasg<div></div></div>" |
sanitizeHtml(html, {
transformTags: {
'*': function(tagName, attribs) {
if (attribs.hasOwnProperty("data-keep")) {
return {
tagName: tagName,
}
} else {
return {
tagName: tagName,
text: ''
}
}
},
}
}) |
The bug seems to be with |
Sounds like you're right. PRs welcome... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Feature request:
If a tag contains a custom data attribute
Eg
Configure to discard the inner contents.
The text was updated successfully, but these errors were encountered: