Skip to content

Commit e12fffc

Browse files
committed
fix: properly clean up multi-root components (testing-library#295)
1 parent d46ed8f commit e12fffc

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Diff for: src/render.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Check out the test examples on GitHub for further details.`)
3434
// https://github.com/vuejs/vue-test-utils-next/blob/master/src/mount.ts#L309
3535
unwrapNode(wrapper.parentElement)
3636

37-
mountedWrappers.add(wrapper)
37+
mountedWrappers.add({wrapper, container})
3838

3939
return {
4040
container,
@@ -59,9 +59,9 @@ function cleanup() {
5959
mountedWrappers.forEach(cleanupAtWrapper)
6060
}
6161

62-
function cleanupAtWrapper(wrapper) {
63-
if (wrapper.element?.parentNode?.parentNode === document.body) {
64-
document.body.removeChild(wrapper.element.parentNode)
62+
function cleanupAtWrapper({wrapper, container}) {
63+
if (container.parentNode === document.body) {
64+
document.body.removeChild(container)
6565
}
6666

6767
wrapper.unmount()

0 commit comments

Comments
 (0)