Skip to content

v-with fails silently if component has replace: true and more than 1 root element #655

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

Closed
Cyancat opened this issue Dec 25, 2014 · 6 comments
Labels

Comments

@Cyancat
Copy link

Cyancat commented Dec 25, 2014

See this: http://jsfiddle.net/qm2wqg8u/5/

If replace set to true, and a multi root template could cause the param can't pass into component. In this case, the comment block cause the problem.

@agonbina
Copy link

@Cyancat I'm not sure I understand what you're trying to do here, can you explain what a "multi root template" is exactly? I don't see any reason why you would want to set a data property on a view model and then use v-with to override that value when there is many other ways you can do that.

@Cyancat
Copy link
Author

Cyancat commented Jan 31, 2015

@agonbina
Set the default data is not the issue, this issue is just about v-with, which not work properly in this case.
Here is a simple one without the default data: http://jsfiddle.net/qm2wqg8u/6/

About "multi root template":
This is a single root template: template: '<div></div>'
This is a multi root template: template: '<div></div><div></div>'
In this case, the comment block make the template as a multi root type: template: '<div></div><!-- comment -->'

Here have a complicated example which include all cases, which you could see the different caused by the structure of template.
http://jsfiddle.net/qm2wqg8u/4/

@yyx990803
Copy link
Member

This is actually because: when the template contains more than one node, the component becomes a "block component", which means it doesn't have a root node (but rather a DocumentFragment). So directives that were attached to the placeholder like v-with are lost during the transclusion. Theoretically this can be fixed though.

@yyx990803 yyx990803 changed the title An issue about 'replace' v-with fails silently if component has replace: true and more than 1 root element Feb 2, 2015
@Craga89
Copy link

Craga89 commented Feb 21, 2015

+1 for a fix on this, I've recently run into this myself. As a workaround, I'm utilising inherit: true for the time being. Is this a priority to be fixed? Its a rather glaring issue imo.

@yyx990803
Copy link
Member

Fixed!

@Cyancat
Copy link
Author

Cyancat commented Feb 25, 2015

@yyx990803
Thanks a lot! Looking forward to formal release :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants