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

[GLIMMER2] Fix ember-glimmer iterators when handling dupes in ({{#each}}) #13763

Merged
merged 1 commit into from
Jun 29, 2016

Conversation

zackthehuman
Copy link
Contributor

@zackthehuman zackthehuman commented Jun 27, 2016

The purpose of this PR is to fix array iteration via {{#each}} in Glimmer2 when the iteratee contains duplicate items. The following tests from ember-glimmer/tests/integration/syntax/each-test.js are now passing for Glimmer2:

  • it can render duplicate primitive items
  • it can render duplicate objects

Key changes:

  • The order that we check objects for array-like-ness changed such that we look for Emberish arrays before plain JS arrays. Emberish arrays seemed to be falling into the plain JS array check -- which seems wrong.
  • ArrayIterator and EmberArrayIterator now keep track of the keys they've seen, and when a duplicate key is seen it creates a composite key using a GUID of the array as a separator.

@@ -41,20 +41,34 @@ class ArrayIterator {
this.length = array.length;
this.keyFor = keyFor;
this.position = 0;
this.guid = null;
this.seen = {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a dict.

@chadhietala
Copy link
Contributor

LGTM

@krisselden krisselden merged commit 183f646 into emberjs:master Jun 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants