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

[BUG] evaluation of object expression fails in nested each loops #2691

Closed
dharmax opened this issue May 20, 2019 · 7 comments
Closed

[BUG] evaluation of object expression fails in nested each loops #2691

dharmax opened this issue May 20, 2019 · 7 comments
Assignees

Comments

@dharmax
Copy link

dharmax commented May 20, 2019

  1. Describe your issue:
    Hello!
    i created a component with a nested loop:
 <li each="{i in state.items}" onclick="{()=>itemClick(i)}" class="{isPreselected(i)?'preselected':''}">
                <span each="{f in props.projection}">{i[f]}</span>
 </li>

An error was thrown, saying f was undefined.
Currently, i work around it, using a method:

<li each="{i in state.items}" onclick="{()=>itemClick(i)}" class="{isPreselected(i)?'preselected':''}">
                <span each="{f in props.projection}">{getField(i,f)}</span>
            </li>

and getField is simply returns i[f] and it works fine.

  1. Can you reproduce the issue?

  2. On which browser/OS does the issue appear?
    i checked only on Chrome

  3. Which version of Riot does it affect?
    version 4.0.0.rc-14 (latest) and down.

@GianlucaGuarini
Copy link
Member

Could you please create a simple demo demonstrating the issue?

@dharmax
Copy link
Author

dharmax commented May 21, 2019

Sure. Is there a working skeletal riot 4 plnkr or something i could use?

@GianlucaGuarini
Copy link
Member

@dharmax
Copy link
Author

dharmax commented May 21, 2019

@GianlucaGuarini
Copy link
Member

Ok I have found the issue, it's a compiler problem will fix it asap

@dharmax
Copy link
Author

dharmax commented May 21, 2019 via email

@GianlucaGuarini
Copy link
Member

Fixed in riot@4.0.0-rc.17. The problem wasn't in the loop directives but in the compiler: computed MemberExpressions foo[bar] weren't properly scoped. Thanks to the new code managing these issues it's easy like a pie!

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

No branches or pull requests

2 participants