-
-
Notifications
You must be signed in to change notification settings - Fork 723
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
Return removed elements after sanitize call #888
Comments
Hmm, not sure if I understand the use case fully. What is the problem with using |
My idea to have something like
to check and return removed and sanitized elements in one component scope. Right now i'm trying to use Map where i collect elements by specific component id but this solution far from ideal 😅. |
I see, can you not make the hook check for the component scope and treat elements conditionally? |
Codesandbox here example.
|
Ah, I see. And if we had a hook registered inside const _forceRemove = function (node) {
arrayPush(DOMPurify.removed, { element: node });
try {
// eslint-disable-next-line unicorn/prefer-dom-node-remove
node.parentNode.removeChild(node);
} catch (_) {
node.remove();
}
}; |
Yep, i think so. at least we can give a try 😅 |
I am not against adding this, if you can confirm that it works and where exactly the hook should be placed in this method, I can add it. Or a PR from you 🙂 |
Ok, will fork project and give a try on local build. Thanks! Will let you know after |
Due to some policies i cannot work on this by myself. Discovered yesterday 😅. And we will need some key for this hook as well otherwise
and then in hook
but not sure if you will like this change 😅 |
Oh, haha - okay :) Will do that now, let me know if we can do anything. |
Hi,
Is there better approach than overriding push https://stackoverflow.com/a/5100420 or using
uponSanitizeElement
hook to get removed elements after sanitize call?With this config removed will be always in array but i need to get all scripts before html rendered and store them per component.
uponSanitizeElement
can't be used because hook will fire globally and will update other elements as wellThe text was updated successfully, but these errors were encountered: