Skip to content

Commit

Permalink
fix npe on build when an array contains undefined values
Browse files Browse the repository at this point in the history
  • Loading branch information
FloGou committed Aug 9, 2016
1 parent 470639c commit 8cf0877
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function ActiveRecord(model, name) {
var populated = options[key].map(function (value) {
if (typeof value === 'string' && _this[key] && Array.isArray(_this[key])) {
var found = _this[key].find(function (element) {
return element._id === value;
return element && element._id === value;
});
if (found) return found;
}
Expand Down
2 changes: 1 addition & 1 deletion dest/temp/ActiveRecord.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function ActiveRecord(model, name) {
var populated = options[key].map(function (value) {
if (typeof value === 'string' && _this[key] && Array.isArray(_this[key])) {
var found = _this[key].find(function (element) {
return element._id === value;
return element && element._id === value;
});
if (found) return found;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"author": "flogou <[email protected]>",
"name": "angular-orm",
"version": "1.1.0",
"version": "1.1.1",
"description": "",
"homepage": "",
"dependencies": {},
Expand Down
2 changes: 1 addition & 1 deletion src/ActiveRecord.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function ActiveRecord(model, name){
(value)=>{
if (typeof value === 'string' && this[key] && Array.isArray(this[key])){
let found = this[key].find((element) => {
return element._id === value
return element && element._id === value
});
if (found) return found
}
Expand Down

0 comments on commit 8cf0877

Please sign in to comment.