Skip to content

v-with not working on a <tr> element #680

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
multimeric opened this issue Jan 17, 2015 · 3 comments
Closed

v-with not working on a <tr> element #680

multimeric opened this issue Jan 17, 2015 · 3 comments

Comments

@multimeric
Copy link

This is a very specific issue that only seems to be happening with <tr> elements. Here's a JSFiddle showing the behaviour. Basically the value extra that is passed in via v-with is not defined in the first 3 rows, but is in the second 3 rows. The only difference between them is their templates.

Here's the code from the fiddle:

<table>
    <tr v-repeat="list" v-with="extra: 300" v-component="doesnt-work"></tr>
    <tr><td><hr></td></tr>
    <tr v-repeat="list" v-with="extra: 300" v-component="does-work"></tr>
</table>
new Vue({
    el: "body",
    data: {
        list: [1, 2, 3]
    },
    components: {
        "doesnt-work": {
            template: "<tr><td>Value: {{$value}}</td></tr>" +
                "<tr><td>Extra: {{extra}}</td></tr>",
            replace: true
        },
        "does-work": {
            template: "<tr><td>Extra: {{extra}}</td></tr>",
            replace: true
        }
    }
});

And the output is:

Value: 1
Extra:
Value: 2
Extra:
Value: 3
Extra:
***
Extra: 300
Extra: 300
Extra: 300
@cheapsteak
Copy link
Contributor

Looks like it's an issue with having more than one root element in the template.
Switching the table to divs recreates the same problem:
http://jsfiddle.net/oLkd7sqn/5/
And adding an (albeit invalid) <div> wrapper around it fixed it
http://jsfiddle.net/oLkd7sqn/6/

@cheapsteak
Copy link
Contributor

Possible a duplicate of this:
v-with fails silently if component has replace: true and more than 1 root element #655

@multimeric
Copy link
Author

Yes I think you're right that it's a duplicate of that issue. I guess I'll leave the discussion to that thread!

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

No branches or pull requests

2 participants