Skip to content

Commit

Permalink
Ember.warn when ManyArray.objectAt() is underfined
Browse files Browse the repository at this point in the history
  • Loading branch information
bagby committed Mar 27, 2017
1 parent 8e600fe commit 44ffbff
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 44ffbff

Please sign in to comment.