Skip to content
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

Don't remove root element from the DOM on destroy #13

Merged
merged 1 commit into from
Jun 20, 2024

Conversation

merlinfuchs
Copy link
Member

The element that the widget is bound to is not created by it and should therefore not be removed from the DOM when the widget is destroyed. Instead, this removes all children and the styling.

@merlinfuchs merlinfuchs requested a review from gzuidhof May 30, 2024 12:40
@CLAassistant
Copy link

CLAassistant commented May 30, 2024

CLA assistant check
All committers have signed the CLA.

@@ -352,7 +352,9 @@ export class FriendlyCaptchaSDK {
send({ type: "root_destroy_widget" });
this.bus.removeTarget(widgetId);
this.widgets.delete(widgetId);
opts.element.remove();

opts.element.innerHTML = "";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this may trigger CSP setups without unsafe-inline (but I'm not entirely sure: you could validate by writing a test for it in sdktest). If it does pose a problem, I imagine we can loop over the children and remove them one by one.

@gzuidhof gzuidhof merged commit 0fe2d34 into main Jun 20, 2024
2 checks passed
@gzuidhof gzuidhof deleted the fix-element-removal branch June 20, 2024 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants