Skip to content

Cleanup targets as well as components #10

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

Closed
EmilTholin opened this issue May 3, 2019 · 1 comment
Closed

Cleanup targets as well as components #10

EmilTholin opened this issue May 3, 2019 · 1 comment

Comments

@EmilTholin
Copy link
Contributor

The great cleanup function destroys all the created components, but the targets are still around. What do you think about extending the cleanupAtContainer function to remove the target DOM nodes that were created as childen of body, like react-testing-library does?

 export const render = (Component, options) => {
   // ...

-  mountedContainers.add(component)
+  mountedContainers.add({target, component})

   // ...
 }

- const cleanupAtContainer = container => {
+ const cleanupAtContainer = obj => {
+   const {target, component} = obj
-   container.$destroy()
+   component.$destroy()
+   if (target.parentNode === document.body) {
+     document.body.removeChild(target)
+   }
-   mountedContainers.delete(container)
+   mountedContainers.delete(obj)
  }
@benmonro
Copy link
Member

benmonro commented May 3, 2019

Sure!

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

No branches or pull requests

2 participants