Skip to content

Cleanup targets as well as components #10

Closed
@EmilTholin

Description

@EmilTholin

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)
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions