@@ -47,6 +47,14 @@ function arrayObserversHelper(obj, target, opts, operation, notify) {
4747 return obj ;
4848}
4949
50+ export function objectAt ( content , idx ) {
51+ if ( content . objectAt ) {
52+ return content . objectAt ( idx ) ;
53+ }
54+
55+ return content [ idx ] ;
56+ }
57+
5058// ..........................................................
5159// ARRAY
5260//
@@ -148,16 +156,12 @@ export default Mixin.create(Enumerable, {
148156 @public
149157 */
150158 objectsAt ( indexes ) {
151- var self = this ;
152-
153- return indexes . map ( function ( idx ) {
154- return self . objectAt ( idx ) ;
155- } ) ;
159+ return indexes . map ( idx => objectAt ( this , idx ) ) ;
156160 } ,
157161
158162 // overrides Ember.Enumerable version
159163 nextObject ( idx ) {
160- return this . objectAt ( idx ) ;
164+ return objectAt ( this , idx ) ;
161165 } ,
162166
163167 /**
@@ -182,11 +186,11 @@ export default Mixin.create(Enumerable, {
182186 } ) ,
183187
184188 firstObject : computed ( function ( ) {
185- return this . objectAt ( 0 ) ;
189+ return objectAt ( this , 0 ) ;
186190 } ) ,
187191
188192 lastObject : computed ( function ( ) {
189- return this . objectAt ( get ( this , 'length' ) - 1 ) ;
193+ return objectAt ( this , get ( this , 'length' ) - 1 ) ;
190194 } ) ,
191195
192196 // optimized version from Enumerable
@@ -235,7 +239,7 @@ export default Mixin.create(Enumerable, {
235239 }
236240
237241 while ( beginIndex < endIndex ) {
238- ret [ ret . length ] = this . objectAt ( beginIndex ++ ) ;
242+ ret [ ret . length ] = objectAt ( this , beginIndex ++ ) ;
239243 }
240244
241245 return ret ;
@@ -277,7 +281,7 @@ export default Mixin.create(Enumerable, {
277281 }
278282
279283 for ( idx = startAt ; idx < len ; idx ++ ) {
280- if ( this . objectAt ( idx ) === object ) {
284+ if ( objectAt ( this , idx ) === object ) {
281285 return idx ;
282286 }
283287 }
@@ -321,7 +325,7 @@ export default Mixin.create(Enumerable, {
321325 }
322326
323327 for ( idx = startAt ; idx >= 0 ; idx -- ) {
324- if ( this . objectAt ( idx ) === object ) {
328+ if ( objectAt ( this , idx ) === object ) {
325329 return idx ;
326330 }
327331 }
@@ -434,7 +438,7 @@ export default Mixin.create(Enumerable, {
434438 lim = startIdx + removeAmt ;
435439
436440 for ( var idx = startIdx ; idx < lim ; idx ++ ) {
437- removing . push ( this . objectAt ( idx ) ) ;
441+ removing . push ( objectAt ( this , idx ) ) ;
438442 }
439443 } else {
440444 removing = removeAmt ;
@@ -482,7 +486,7 @@ export default Mixin.create(Enumerable, {
482486 lim = startIdx + addAmt ;
483487
484488 for ( var idx = startIdx ; idx < lim ; idx ++ ) {
485- adding . push ( this . objectAt ( idx ) ) ;
489+ adding . push ( objectAt ( this , idx ) ) ;
486490 }
487491 } else {
488492 adding = addAmt ;
@@ -500,12 +504,12 @@ export default Mixin.create(Enumerable, {
500504 var cachedFirst = cacheFor ( this , 'firstObject' ) ;
501505 var cachedLast = cacheFor ( this , 'lastObject' ) ;
502506
503- if ( this . objectAt ( 0 ) !== cachedFirst ) {
507+ if ( objectAt ( this , 0 ) !== cachedFirst ) {
504508 propertyWillChange ( this , 'firstObject' ) ;
505509 propertyDidChange ( this , 'firstObject' ) ;
506510 }
507511
508- if ( this . objectAt ( length - 1 ) !== cachedLast ) {
512+ if ( objectAt ( this , length - 1 ) !== cachedLast ) {
509513 propertyWillChange ( this , 'lastObject' ) ;
510514 propertyDidChange ( this , 'lastObject' ) ;
511515 }
0 commit comments