Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
Removing duplicates resources when filtering by context, giving prece…
Browse files Browse the repository at this point in the history
…dence to duplicates with lower indeces.
  • Loading branch information
aljimenez committed Mar 13, 2014
1 parent 46edd6a commit 44f8646
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/resources.js
Expand Up @@ -664,13 +664,15 @@ ShakerResources.prototype = {
if (!bySelector[res.selector]) {
bySelector[res.selector] = {};
}
bySelector[res.selector][res.id] = res;
// duplicates that come first have higher precedence
bySelector[res.selector][res.id] = bySelector[res.selector][res.id] || res;
}
for (s = posl.length; s > 0; s -= 1) {
selector = posl[s - 1];
for (r in bySelector[selector]) {
if (bySelector[selector].hasOwnProperty(r)) {
out[r] = bySelector[selector][r];
// duplicates that come first have higher precedence
out[r] = out[r] || bySelector[selector][r];
}
}
}
Expand Down Expand Up @@ -892,7 +894,7 @@ ShakerResources.prototype = {
if ((rawResource.source.pkg.name === 'mojito' || rawResource.source.pkg.name === 'mojito-shaker') &&
(rawResource.affinity.affinity === 'common' || rawResource.affinity.affinity === 'client') &&
rawResource.source.fs.ext === '.js') {
self._mojitoResources[rawResource.name] = rawResource;
self._mojitoResources[rawResource.name] = self._mojitoResources[rawResource.name] || rawResource;
}
}

Expand Down

0 comments on commit 44f8646

Please sign in to comment.