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

looped item property compile problem #2788

Closed
6 tasks
agreif opened this issue Dec 6, 2019 · 1 comment
Closed
6 tasks

looped item property compile problem #2788

agreif opened this issue Dec 6, 2019 · 1 comment
Assignees

Comments

@agreif
Copy link

agreif commented Dec 6, 2019

Help us to manage our issues by answering the following:

  1. Describe your issue:

in a tag with 'each' item properties are not read correctly.
the error is 'TypeError: scope.item.scope is undefined'

The problem is that the compiler does generate
return scope.classNames({active: scope.item.scope.isActive});
instead of
return scope.classNames({active: scope.item.scope.isActive});

  1. Can you reproduce the issue?
    yes, see tag below.
    BTW I took the 'classNames' function from the homepage
<my-tag>
	<select multiple>
	  <option class="{classNames({active: item.isActive})}" each="{item in items}">
	    {item.name}
	  </option>
	</select>

  <style>
    .active { font-weight: bolder; }
  </style>

  <script>
    export default {
      items: [
        {name: "foo", isActive: true},
        {name: "bar", isActive: false},
      ],
      classNames: (classes) => {
        return Object.entries(classes).reduce((acc, item) => {
          const [key, value] = item
          if (value) return [...acc, key]
          return acc
          }, []).join(' ')
      }
    }
  </script>

</my-tag>

https://plnkr.co/edit/f5q714B2Ay6Cw8cQVf3n?p=preview

  1. On which browser/OS does the issue appear?
    'all'

  2. Which version of Riot does it affect?
    '4.6.2 and also the current master'

  3. How would you tag this issue?

  • Question
  • [*] Bug
  • Discussion
  • Feature request
  • Tip
  • Enhancement
  • Performance
@GianlucaGuarini
Copy link
Member

Thank you for reporting the issue it was fixed in Riot.jst@4.7.1

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

Successfully merging a pull request may close this issue.

2 participants