Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add provided/inject support for Composition API components #1354

Merged
merged 18 commits into from
Dec 18, 2019

Conversation

Stoom
Copy link
Contributor

@Stoom Stoom commented Nov 22, 2019

It looks like with the new composition api components that the provider changed from vm.provide to vm._provided. This PR adds both so that composition apis that use injection can be tested.

@Stoom
Copy link
Contributor Author

Stoom commented Nov 22, 2019

The latest build fail is flow issues in wrapper. Looks to be an issue with the dev branch

Copy link
Contributor

@dobromir-hristov dobromir-hristov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@@ -0,0 +1,4 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not a great idea. We should not keep such files in the repo.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm... I'm not a VSCode user. I can go download VSCode and try to setup our repo with it, but from googling, it seems like this file is needed for flow https://code.visualstudio.com/docs/languages/javascript#_can-i-use-other-javascript-tools-like-flow

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to configure this myself too when setting up the local env yesterday. Not sure if committing it here is the best approach (I've done so in my projects), but it's gonna be needed for every VSC user.

Copy link
Collaborator

@JessicaSachs JessicaSachs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for this PR 🎉! Two small changes and one question:

  1. Can you place the composition API in the devDependencies?
  2. Can you assert that setInBeforeCreate is equal to created in your test?

Question: Would it be helpful for you as a VSCode user if the settings.json file was there when you first cloned the project?

package.json Outdated Show resolved Hide resolved
@@ -0,0 +1,4 @@
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm... I'm not a VSCode user. I can go download VSCode and try to setup our repo with it, but from googling, it seems like this file is needed for flow https://code.visualstudio.com/docs/languages/javascript#_can-i-use-other-javascript-tools-like-flow

@JessicaSachs
Copy link
Collaborator

The tests are failing due to some prettier issue on dev that has since been fixed. Can you rebase and re-push?

@Stoom
Copy link
Contributor Author

Stoom commented Dec 18, 2019

Should be good now @JessicaSachs

@JessicaSachs
Copy link
Collaborator

I think the flow upgrade also caused a failure... Lemme revert the flow bin locally and test what happens

@Stoom
Copy link
Contributor Author

Stoom commented Dec 18, 2019

Looks like flow errors?

@JessicaSachs
Copy link
Collaborator

Yeah, pin the version to 0.66.0 and re-run yarn install. That fixes the errors for me.

@Stoom
Copy link
Contributor Author

Stoom commented Dec 18, 2019

Yeah, pin the version to 0.66.0 and re-run yarn install. That fixes the errors for me.

^0.66.0?

@JessicaSachs
Copy link
Collaborator

^0.66.0 Will be fine for now. I'm probably going to pin it at 0.66.0 after the merge, until we have a chance to fix the Element issues so someone doesn't accidentally upgrade it.

@JessicaSachs JessicaSachs merged commit a05b499 into vuejs:dev Dec 18, 2019
@vue-bot
Copy link

vue-bot commented Dec 18, 2019

Hey @Stoom, thank you for your time and effort spent on this PR, contributions like yours help make Vue better for everyone. Cheers! 💚

Copy link
Contributor

@dobromir-hristov dobromir-hristov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those test cases look a bit unpolished. Overall is OK.

!injectSupported || mountingMethod.name === 'renderToString',
'supports setup in composition api component',
() => {
if (!injectSupported) return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the point of this? It is already checked above?

localVue
})

expect(wrapper.vm.setInSetup).to.equal('created')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this connected to provide/inject?

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.

5 participants