angular/angular.js — pull request #2505 by spamdaemon (2013-04-25 02:49:41+00:00)
Title: Allow duplicate objects in ngRepeat.

Currently, ngRepeat doesn't allow modification of a list that contains
duplicates. For example, while ng-repeat='i in [1,1,1]' is allowed, it
is not possible to add a 1 to the list after it has been iterated at
least once. This patch addresses this issue.
Just by observing a change from [1,1,1] to [1,1,1,1] it is not possible
to know the position where the additional 1 was inserted (vice versa for
removal of 1). For the purposes of this patch, we assume that the item
was inserted after all other duplicates (or is the last duplicate to be
removed).
This patch does have a visible effect when using animations. Consider
the following list [a,b,a] and inserting a in position 0 to yield
[a,a,b,a]. Since we're assuming that a was added, we need to apply a
series of moves to yield the desired list:
* a in position 0 does not change
* a moves from position 2 to position 1
* b moves from position 1 to position 2
* a new a is added in position 3
It is probably possible to minimize the number of moves necessary, but that
would come at some cost.
This patch assumes that no two objects that are not occupying the same
memory location will have the same $$hashKey (which is the same
assumption of the previous implementation but it was not stated!)