@@ -88,7 +88,7 @@ var ngRepeatDirective = ngDirective({
88
88
// We need an array of these objects since the same object can be returned from the iterator.
89
89
// We expect this to be a rare case.
90
90
var lastOrder = new HashQueueMap ( ) ;
91
- var indexValues = [ ] ;
91
+
92
92
scope . $watch ( function ngRepeatWatch ( scope ) {
93
93
var index , length ,
94
94
collection = scope . $eval ( rhs ) ,
@@ -119,18 +119,14 @@ var ngRepeatDirective = ngDirective({
119
119
key = ( collection === array ) ? index : array [ index ] ;
120
120
value = collection [ key ] ;
121
121
122
- // if collection is array and value is object, it can be shifted to allow for position change
123
- // if collection is array and value is not object, need to first check whether index is same to
124
- // avoid shifting wrong value
125
- // if collection is not array, need to always check index to avoid shifting wrong value
126
- if ( lastOrder . peek ( value ) ) {
127
- last = collection === array ?
128
- ( ( isObject ( value ) ) ? lastOrder . shift ( value ) :
129
- ( index === lastOrder . peek ( value ) . index ? lastOrder . shift ( value ) : undefined ) ) :
130
- ( index === lastOrder . peek ( value ) . index ? lastOrder . shift ( value ) : undefined ) ;
131
- } else {
132
- last = undefined ;
133
- }
122
+ // if value is object, it can be shifted to allow for position change
123
+ // if is not object, need to first check whether index is same to avoid shifting wrong val
124
+ last = isObject ( value )
125
+ ? lastOrder . shift ( value )
126
+ : ( last = lastOrder . peek ( value ) ) && ( index === last . index )
127
+ ? lastOrder . shift ( value )
128
+ : undefined ;
129
+
134
130
135
131
if ( last ) {
136
132
// if we have already seen this object, then we need to reuse the
@@ -151,12 +147,6 @@ var ngRepeatDirective = ngDirective({
151
147
cursor = last . element ;
152
148
}
153
149
} else {
154
- if ( indexValues . hasOwnProperty ( index ) && collection !== array ) {
155
- var preValue = indexValues [ index ] ;
156
- var v = lastOrder . shift ( preValue ) ;
157
- v . element . remove ( ) ;
158
- v . scope . $destroy ( ) ;
159
- }
160
150
// new item which we don't know about
161
151
childScope = scope . $new ( ) ;
162
152
}
@@ -178,16 +168,10 @@ var ngRepeatDirective = ngDirective({
178
168
index : index
179
169
} ;
180
170
nextOrder . push ( value , last ) ;
181
- indexValues [ index ] = value ;
182
171
} ) ;
183
172
}
184
173
}
185
174
186
- var i , l ;
187
- for ( i = 0 , l = indexValues . length - length ; i < l ; i ++ ) {
188
- indexValues . pop ( ) ;
189
- }
190
-
191
175
//shrink children
192
176
for ( key in lastOrder ) {
193
177
if ( lastOrder . hasOwnProperty ( key ) ) {
0 commit comments