Skip to content

Commit

Permalink
fix(core): fixes Collection.reference
Browse files Browse the repository at this point in the history
  • Loading branch information
rafamel committed Nov 24, 2019
1 parent abc1dea commit 16d7690
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/core/src/classes/Collection/helpers/reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,17 @@ export function reference(
const isArray = Array.isArray(names);
const arr = (isArray ? names : [names]) as string[];

for (const mode of modes) {
for (const name of arr) {
if (!containsKey(collection[mode], name)) {
throw Error(`Can't reference "${name}" on collection`);
for (const name of arr) {
let found = false;
for (const mode of modes) {
if (containsKey(collection[mode], name)) {
found = true;
break;
}
}
if (!found) {
throw Error(`Can't reference "${name}" on collection`);
}
}

return isArray ? arr : arr[0];
Expand Down

0 comments on commit 16d7690

Please sign in to comment.