1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | module.exports = function traverse(element, fn) {
|
9 | fn(element);
|
10 |
|
11 | var descriptor = element.$descriptor;
|
12 |
|
13 | if (descriptor.isGeneric) {
|
14 | return;
|
15 | }
|
16 |
|
17 | var containedProperties = descriptor.properties.filter(p => {
|
18 | return !p.isAttr && !p.isReference && p.type !== 'String';
|
19 | });
|
20 |
|
21 | containedProperties.forEach(p => {
|
22 | if (p.name in element) {
|
23 | const propertyValue = element[p.name];
|
24 |
|
25 | if (p.isMany) {
|
26 | propertyValue.forEach(child => {
|
27 | traverse(child, fn);
|
28 | });
|
29 | } else {
|
30 | traverse(propertyValue, fn);
|
31 | }
|
32 | }
|
33 | });
|
34 | };
|