source: imaps-frontend/node_modules/clean-css/lib/optimizer/level-2/properties/find-component-in.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 950 bytes
Line 
1var configuration = require('../../configuration');
2
3function findComponentIn(shorthand, longhand) {
4 var comparator = nameComparator(longhand);
5
6 return findInDirectComponents(shorthand, comparator) || findInSubComponents(shorthand, comparator);
7}
8
9function nameComparator(to) {
10 return function(property) {
11 return to.name === property.name;
12 };
13}
14
15function findInDirectComponents(shorthand, comparator) {
16 return shorthand.components.filter(comparator)[0];
17}
18
19function findInSubComponents(shorthand, comparator) {
20 var shorthandComponent;
21 var longhandMatch;
22 var i, l;
23
24 if (!configuration[shorthand.name].shorthandComponents) {
25 return;
26 }
27
28 for (i = 0, l = shorthand.components.length; i < l; i++) {
29 shorthandComponent = shorthand.components[i];
30 longhandMatch = findInDirectComponents(shorthandComponent, comparator);
31
32 if (longhandMatch) {
33 return longhandMatch;
34 }
35 }
36}
37
38module.exports = findComponentIn;
Note: See TracBrowser for help on using the repository browser.