Skip to content

Commit 9137931

Browse files
committed
fix: resolve conversation
1 parent 000b3e8 commit 9137931

File tree

2 files changed

+5
-26
lines changed

2 files changed

+5
-26
lines changed

src/__tests__/render.js

+4-21
Original file line numberDiff line numberDiff line change
@@ -89,31 +89,14 @@ test('unmounts', () => {
8989
expect(queryByTestId('node')).not.toBeInTheDocument()
9090
})
9191

92-
test('use unmount before cleanup', () => {
93-
const TestComponent = defineComponent((_, {slots}) => {
94-
return () => slots.default?.()
95-
})
92+
test('unmounts when no wrapper element is present', () => {
93+
const Comp = defineComponent((_, ctx) => () => ctx.slots.default?.())
9694

97-
const {getByTestId, unmount, queryByTestId} = render({
98-
render() {
99-
return h(
100-
TestComponent,
101-
{},
102-
{
103-
default: () =>
104-
h('div', {
105-
'data-testid': 'node',
106-
}),
107-
},
108-
)
109-
},
95+
const {unmount} = render({
96+
render: () => h(Comp, () => h('div')),
11097
})
11198

112-
expect(getByTestId('node')).toBeInTheDocument()
113-
11499
unmount()
115100

116-
expect(queryByTestId('node')).not.toBeInTheDocument()
117-
118101
expect(() => cleanup()).not.toThrow()
119102
})

src/render.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,7 @@ function cleanup() {
6060
}
6161

6262
function cleanupAtWrapper(wrapper) {
63-
if (
64-
wrapper.element &&
65-
wrapper.element.parentNode &&
66-
wrapper.element.parentNode.parentNode === document.body
67-
) {
63+
if (wrapper.element?.parentNode?.parentNode === document.body) {
6864
document.body.removeChild(wrapper.element.parentNode)
6965
}
7066

0 commit comments

Comments
 (0)