Famous / Famous/framework

$repeat does not repeat

Open
#72 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
394
Forks
62
PR merge metrics
No merged PRs in 30d

Description

If you run this example, Framework will only generate 1 div at position 50, 50 where I would expect it to create two, one at 0, 0 and the second at 50, 50. Also, the console.log($index) prints two 1's, instead of a 0 and a 1. Strange...

```
FamousFramework.component('m:test', {
behaviors: {
'.item': {
'$repeat': [0, 1],
'position': ($index) => {
console.log($index);
return [$index * 50, $index * 50]
},
'content': ($index) => {
return `

${$index}
`
}
}
},
events: {},
states: {},
tree: `

`
});
```

EDIT: Hmm… just saw this seems to happen whenever the list you try to repeat over does not contain objects… So for example if you `'$repeat’: [0, 1]` it does not seem to create two elements, but if instead you `'$repeat’: [{foo: ‘hello’}, {foo: ‘world'}]` then it does create two elements…!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.