Skip to content

Conversation

pikax
Copy link
Member

@pikax pikax commented Apr 18, 2020

add unmount to the wrapper

Named unmount to be inline with vue3

Not throwing exception when you unmount multi times, because vue3 only warns

https://github.com/vuejs/vue-next/blob/a51b05267231fb1770d6fc727bc276475c21d27f/packages/runtime-core/src/apiCreateApp.ts#L233-L239

@lmiller1990
Copy link
Member

lmiller1990 commented Apr 18, 2020

Hi! Thanks for the PR.

We aren't looking to expand the API much right; but maintain the API from VTU beta. Is there a specific reason why you need this functionality in your app?

If you are looking to contribute, we had a destroy method on the VueWrapper in beta. (Or did $destroy become unmount? I may have missed this).

Ideally, we should create an issue to discuss new features before adding them. Don't let that stop you - feel free to create one for some discussion, if you think this feature is valuable.

@pikax
Copy link
Member Author

pikax commented Apr 18, 2020

isn't unmount and destroy the same thing?

I thought the wrapper.destroy method is called destroy to keep the same name as vm.$destroy in v2

In v3 the destroy was renamed to unmount lifecycle-hooks

We can have a destroy method that calls unmount with an deprecated warning (I think that's what will happen on v2.7)

@lmiller1990
Copy link
Member

Right, I didn't know they had renamed that hook. Makes sense.

In this case it's maintaining an existing API so I think this PR makes sense.

I don't think we need a deprecation warning; we are targeting Vue 3 exclusively, where there is no destroy.

Looks good to me. I will look for one more approval and merge this up. If you want, you can mark destroy as completed in the README with a note that it was renamed.

# Conflicts:
#	src/mount.ts
#	src/vue-wrapper.ts
@pikax
Copy link
Member Author

pikax commented Apr 19, 2020

Just merged with master, but I have a question, when we use findComponent it will return a new instance of VueWrapper, my question is do we allow to unmount that component instance?

const c = wrapper.findComponent({ ref: 'refChild' })
c.unmount()

If we allow should we unmount the root as well or only the component?

@lmiller1990
Copy link
Member

I see 0 use case for unmounting a vue wrapper found via findComponent. Let's not do that unless a use case arises.

@lmiller1990 lmiller1990 merged commit 4fefe74 into vuejs:master Apr 20, 2020
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

Successfully merging this pull request may close these issues.

3 participants