main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 6 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
950 bytes
|
Rev | Line | |
---|
[79a0317] | 1 | var configuration = require('../../configuration');
|
---|
| 2 |
|
---|
| 3 | function findComponentIn(shorthand, longhand) {
|
---|
| 4 | var comparator = nameComparator(longhand);
|
---|
| 5 |
|
---|
| 6 | return findInDirectComponents(shorthand, comparator) || findInSubComponents(shorthand, comparator);
|
---|
| 7 | }
|
---|
| 8 |
|
---|
| 9 | function nameComparator(to) {
|
---|
| 10 | return function(property) {
|
---|
| 11 | return to.name === property.name;
|
---|
| 12 | };
|
---|
| 13 | }
|
---|
| 14 |
|
---|
| 15 | function findInDirectComponents(shorthand, comparator) {
|
---|
| 16 | return shorthand.components.filter(comparator)[0];
|
---|
| 17 | }
|
---|
| 18 |
|
---|
| 19 | function 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 |
|
---|
| 38 | module.exports = findComponentIn;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.