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

fix: improve slots option #813

Merged
merged 9 commits into from
Jul 22, 2018
Merged

fix: improve slots option #813

merged 9 commits into from
Jul 22, 2018

Conversation

38elements
Copy link
Contributor

This resolves #793.

const vnode = h(el)
let vnode = h(el)
if (typeof slotValue === 'string') {
const vue = new Vue()
Copy link
Member

Choose a reason for hiding this comment

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

I think this would be a problem if you mount a component that uses localVue and the slot component accesses a property that is only added to the localVue prototype, can you write a test to check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is.
Changing localVue.prototype, this does not work.
Using vm._renderProxy is correct if possible.
I will add test for changing localVue.prototype.

@38elements
Copy link
Contributor Author

This case does not work.
I will make another issue.

slots: {
  default: '<div><component-with-parent-name /></div>'
}

@38elements
Copy link
Contributor Author

I added a test for changing localVue.prototype.
I think this change is temporary solution.
I will seek another solution.

@@ -22,6 +23,12 @@ function createVNodesForSlot (
let vnode = h(el)
if (typeof slotValue === 'string') {
const vue = new Vue()
const _vue = new _Vue()
Copy link
Member

Choose a reason for hiding this comment

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

why not just use the _vue.renderProxy rather than mixing both?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since it raises an error.

@38elements
Copy link
Contributor Author

@eddyerburgh
I sent the pull request for another solution.
It is #821.

@38elements
Copy link
Contributor Author

I think #821 is better than this.

@38elements 38elements closed this Jul 14, 2018
@38elements 38elements reopened this Jul 19, 2018
@38elements 38elements closed this Jul 19, 2018
@38elements 38elements reopened this Jul 19, 2018
const _vue = new _Vue()
for (const key in _vue._renderProxy) {
if (!(vue._renderProxy[key])) {
vue._renderProxy[key] = _vue._renderProxy[key]
Copy link
Member

Choose a reason for hiding this comment

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

Why not always use _vue.renderProxy?

Copy link
Contributor Author

@38elements 38elements Jul 22, 2018

Choose a reason for hiding this comment

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

When vue.renderProxy is used, it raises an error.
When _vue.renderProxy is used, it raises an error.

TypeError: Cannot read property 'Ctor' of undefined

Copy link
Member

Choose a reason for hiding this comment

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

Do you mean when _vue.renderProxy is used?

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 am sorry.
Yes, I do.

}
try {
// $FlowIgnore
vnode = el.render.call(vue._renderProxy, h)
Copy link
Member

Choose a reason for hiding this comment

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

Do components without a render function work here?

For example:

mount(TestComponent,{
  slots: { default: {
    template: '<div />'
  }}
})

Can you add a test for this kind of slot

@eddyerburgh
Copy link
Member

Could you also include a fix for #828? Your previous PR would have solved this (adding a parent div to template strings, and using the child value)

@38elements
Copy link
Contributor Author

I will try to add it.

@38elements
Copy link
Contributor Author

@eddyerburgh
I changed this.
IMHO,
Since #828 does not uses slots, I think this pull request is not related it.
I do not know #734 well.
It seems that this might be related #734.
I think this might resolve #734.

@eddyerburgh
Copy link
Member

Ok sounds good. Can you add the tests from #734 to verify that this PR solves the issue?

@38elements
Copy link
Contributor Author

@eddyerburgh
I added a test for #734.

@eddyerburgh
Copy link
Member

Nice work, thanks :)

@eddyerburgh eddyerburgh merged commit 5fecbd2 into vuejs:dev Jul 22, 2018
@38elements
Copy link
Contributor Author

@eddyerburgh
Thank you for reviewing.
I am sorry.
The test for #734 which is added at this pull request is incorrect.
#734 is not resolved.
I sent a pull request #847.

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.

$parent of a child component defined on a slot, reference to itself
2 participants