#getId() should behave even if the item is null or undefined.

This commit is contained in:
Julien Fontanet 2015-04-08 11:58:46 +02:00
parent 45441653f6
commit f479e914bb

View File

@ -90,7 +90,7 @@ export default class Collection extends EventEmitter {
}
getId (item) {
return item.id
return item && item.id
}
has (key) {
@ -99,9 +99,7 @@ export default class Collection extends EventEmitter {
_resolveItem (keyOrObjectWithId, valueIfKey = null) {
let value
let key = (undefined !== keyOrObjectWithId) ?
this.getId(keyOrObjectWithId) :
undefined
let key = this.getId(keyOrObjectWithId)
if (undefined === key) {
if (arguments.length < 2) {