Skip to content

Commit

Permalink
Merge pull request #4896 from bagby/warn-object-at-undefined
Browse files Browse the repository at this point in the history
Ember.warn when ManyArray.objectAt() is undefined
  • Loading branch information
bmac authored Mar 28, 2017
2 parents d0ea470 + 44ffbff commit 4e77224
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions addon/-private/system/many-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@module ember-data
*/
import Ember from 'ember';
import { assert } from "ember-data/-private/debug";
import { assert, warn } from "ember-data/-private/debug";
import { PromiseArray } from "./promise-proxies";
import { _objectIsAlive } from "./store/common";
import diffArray from './diff-array';
Expand Down Expand Up @@ -136,7 +136,12 @@ export default Ember.Object.extend(Ember.MutableArray, Ember.Evented, {
objectAt(index) {
let object = this.currentState[index];
//Ember observers such as 'firstObject', 'lastObject' might do out of bounds accesses
if (object === undefined) { return; }
if (object === undefined) {
warn(`ManyArray#objectAt(index) return undefined for index '${index}'. See https://github.com/emberjs/data/issues/4758`, false, {
id: 'ds.many-array.object-at-undefined'
});
return;
}

return object.getRecord();
},
Expand Down

0 comments on commit 4e77224

Please sign in to comment.