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

Partial update when sorting array used in repeat.for #275

Closed
RomkeVdMeulen opened this issue Mar 2, 2017 · 3 comments
Closed

Partial update when sorting array used in repeat.for #275

RomkeVdMeulen opened this issue Mar 2, 2017 · 3 comments
Assignees
Labels

Comments

@RomkeVdMeulen
Copy link
Contributor

RomkeVdMeulen commented Mar 2, 2017

I'm submitting a bug report

  • Browser:
    Chrome 55

Current behavior:
See https://gist.run/?id=dca097c25e9950440096048af1373b57.

When using repeat.for on an array, and the array is (re)sorted in place, some of the rendered results are updated correctly and some are not. In the linked example one of the rows is always out of sync with the others. This does not occur if the array is replaced with the sorted version.

Expected/desired behavior:
After a resort, the rendered result in every iteration should be consistent.

@RomkeVdMeulen
Copy link
Contributor Author

Might be related to #265 - I'm not sure.

@jdanyow
Copy link
Contributor

jdanyow commented Mar 12, 2017

<tr repeat.for="row of items">
        <td>
    			${row} ([
      			${items[0]}
      			${items[1]}
      			${items[2]}
      			${items[3]}
      			${items[4]}
      			${items[5]}
    			])
    		</td>
      </tr>

I think I see what's going on here- allow me to try and explain:

Running the gist and clicking "sort in place" causes the ${row} part of the template to update. Also, in rows that had to be moved (row 4 and row 3 needed to be swapped), the ${items[N]} parts of the template were updated. Rows that did not move had their ${items[N]} get out of sync. There's nothing we can do about this because there is no way to observe indexed array access without using Object.observe (deprecated) or dirty-checking. The sort and replace workaround would be my recommendation. With more details on your real scenario we might be able to provide other options.

@jdanyow jdanyow closed this as completed Mar 12, 2017
@RomkeVdMeulen
Copy link
Contributor Author

Thanks for the explanation! I'll stick with sort and replace.

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

No branches or pull requests

3 participants