|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
950 bytes
|
| Line | |
|---|
| 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.