Skip to content

Commit

Permalink
fix: resolve conversation
Browse files Browse the repository at this point in the history
  • Loading branch information
hcg1023 committed Mar 17, 2024
1 parent 000b3e8 commit 9137931
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 26 deletions.
25 changes: 4 additions & 21 deletions src/__tests__/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,31 +89,14 @@ test('unmounts', () => {
expect(queryByTestId('node')).not.toBeInTheDocument()
})

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

const {getByTestId, unmount, queryByTestId} = render({
render() {
return h(
TestComponent,
{},
{
default: () =>
h('div', {
'data-testid': 'node',
}),
},
)
},
const {unmount} = render({
render: () => h(Comp, () => h('div')),
})

expect(getByTestId('node')).toBeInTheDocument()

unmount()

expect(queryByTestId('node')).not.toBeInTheDocument()

expect(() => cleanup()).not.toThrow()
})
6 changes: 1 addition & 5 deletions src/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@ function cleanup() {
}

function cleanupAtWrapper(wrapper) {
if (
wrapper.element &&
wrapper.element.parentNode &&
wrapper.element.parentNode.parentNode === document.body
) {
if (wrapper.element?.parentNode?.parentNode === document.body) {
document.body.removeChild(wrapper.element.parentNode)
}

Expand Down

0 comments on commit 9137931

Please sign in to comment.