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

Inconsistent tags behaviour with 1 item vs many #936

Closed
weepy opened this Issue Jul 8, 2015 · 3 comments

Comments

Projects
None yet
3 participants
@weepy

weepy commented Jul 8, 2015

I have an XY component

<xy>
<cursor each={ data in cursors } ></cursor>
</xy>

If I mount my tag with 1 item in an array:

riot.mount("xy", {
    cursors:  [{}]
})

then this.tags.cursor is a single cursor item

If I mount with cursor: [{}, {}] then this.tags.cursor in an array (expected behaviour)

Is this a bug or a feature ?

weepy

@rsbondi

This comment has been minimized.

Show comment
Hide comment
@rsbondi

rsbondi Jul 8, 2015

Member

This is the expected behavior. It is a trade off, easier if you use single instance to do this.tagname, and also meaningful for multiple tags that are not in a loop, but I can see where it is counter intuitive in a loop. So you would need to check if it is an array and handle accordingly.

Member

rsbondi commented Jul 8, 2015

This is the expected behavior. It is a trade off, easier if you use single instance to do this.tagname, and also meaningful for multiple tags that are not in a loop, but I can see where it is counter intuitive in a loop. So you would need to check if it is an array and handle accordingly.

@rsbondi rsbondi added the question label Jul 8, 2015

@weepy

This comment has been minimized.

Show comment
Hide comment
@weepy

weepy Jul 8, 2015

Perhaps this is part of the implementation, but it seems easy to reason that it should be an array if it was declared via "each" ?

weepy commented Jul 8, 2015

Perhaps this is part of the implementation, but it seems easy to reason that it should be an array if it was declared via "each" ?

@GianlucaGuarini GianlucaGuarini added this to the 3.0.0 milestone Feb 14, 2016

@GianlucaGuarini

This comment has been minimized.

Show comment
Hide comment
@GianlucaGuarini
Member

GianlucaGuarini commented Oct 15, 2016

This issue is fixed in riot@3.0.0 http://plnkr.co/edit/Uyr2Do4976uGKLLzAgtm?p=preview

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment