Skip to content

Commit

Permalink
fix getId to also check for props on the prototype
Browse files Browse the repository at this point in the history
The `getId` check would fail if the `id` property was in somewhere in the prototype chain.  This updates `getId` to also check the prototype properties.
  • Loading branch information
marshallswain committed Oct 23, 2019
1 parent c7af6fa commit 101a7d3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,13 @@ export function getId(item, idField) {
if (!item) {
return
}
if (item.hasOwnProperty('id')) {
if (item.id != null || item.hasOwnProperty('id')) {
return item.id
}
if (item.hasOwnProperty('_id')) {
if (item._id != null || item.hasOwnProperty('_id')) {
return item._id
}
if (item.hasOwnProperty(idField)) {
if (item[idField] != null || item.hasOwnProperty(idField)) {
return item[idField]
}
}
Expand Down

0 comments on commit 101a7d3

Please sign in to comment.