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

Inconsistent tags behaviour with 1 item vs many #936

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

Inconsistent tags behaviour with 1 item vs many #936

weepy opened this issue Jul 8, 2015 · 3 comments
Milestone

Comments

@weepy
Copy link

@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
Copy link
Contributor

@rsbondi 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
Copy link
Author

@weepy 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
Copy link
Member

@GianlucaGuarini 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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.