Skip to content

Passing text to slots #233

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

Merged
merged 8 commits into from
Dec 9, 2017
Merged

Passing text to slots #233

merged 8 commits into from
Dec 9, 2017

Conversation

38elements
Copy link
Contributor

@38elements 38elements commented Dec 6, 2017

This is related to #229.

This support only text as below.

const wrapper = mount(ComponentWithSlots, { slots: { default: 'foobar' }})

This does not work for the text like one as below.

const wrapper = mount(ComponentWithSlots, { slots: { default: 'foo<span>bar</span>' }})
const wrapper = mount(FooComponent, { slots: { default: 'foo {{ bar }}' }})

@38elements 38elements changed the title Passing text to slots #229 Passing text to slots Dec 6, 2017
@eddyerburgh
Copy link
Member

Great, thanks 🙂

The tests failed runnning Vue 2.0.8. It must not add v as an alias. Ideally we'll have a workaround that works in Vue 2.0.8, if you can't find one we can add an error that text slot values aren't supported in Vue 2.0.x

@38elements
Copy link
Contributor Author

38elements commented Dec 6, 2017

Thank you for reply.
I look for ways to solve at Vue 2.0.8.

@38elements
Copy link
Contributor Author

38elements commented Dec 6, 2017

I could not find a way to solve it.
I added a warning.

There is another problem.
The following code does not work.

const wrapper = mount(FooComponent, { slots: { default: 'foo {{ bar }}' }})

I want to make this a different issue.

@@ -25,6 +26,18 @@ describe('mount.slots', () => {
expect(wrapper.contains('span')).to.equal(true)
})

it('mounts component with default slot if passed string in slot object', () => {
const vm = new Vue()
if ('_v' in vm) {
Copy link
Member

Choose a reason for hiding this comment

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

Could you find which Vue version supports _v and then import { vueVersion } from ~resources/test-utils.

So instead of this:

if ('_v' in vm) {

use this:

if (vueVersion > 2.2) {

That way it makes more sense from other developers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed this.

@eddyerburgh eddyerburgh merged commit 790a949 into vuejs:dev Dec 9, 2017
@38elements 38elements deleted the slot branch December 10, 2017 09:33
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.

2 participants