@@ -14,7 +14,7 @@ Description:
14
14
<br />
15
15
<span >{{ elementName }}</span >
16
16
</button >
17
-
17
+ <!-- Child Component Icons -->
18
18
<button
19
19
@click.prevent =" changeState(elementName)"
20
20
v-for =" (elementName, idx) in childrenComp"
@@ -55,33 +55,23 @@ export default {
55
55
elementStorage : function () {
56
56
let computedElementalStorage = {};
57
57
if (this .activeComponent ) {
58
+ computedElementalStorage = {};
58
59
59
- this .componentMap [this .activeComponent ].htmlList .forEach ((el ) => {
60
- if (! computedElementalStorage[el .text ]) {
61
- computedElementalStorage[el .text ] = 1 ;
62
- }
63
- else if (computedElementalStorage[el .text ]) {
64
- computedElementalStorage[el .text ] += 1 ;
65
- }
66
- });
67
- // show the badge for all nested children arrays
68
- const checkChild = array => {
60
+ // function searches through HtmlList and is invoke recursively to search its children(Html Elements that are nested)
61
+ const checkHtmlElements = array => {
69
62
for (let html of array) {
70
- console .log (html)
71
63
if (html .children .length ) {
72
- checkChild (html .children )
64
+ checkHtmlElements (html .children )
65
+ }
66
+ if (! computedElementalStorage[html .text ]) {
67
+ computedElementalStorage[html .text ] = 1
73
68
} else {
74
- if (! computedElementalStorage[html .text ]) {
75
- computedElementalStorage[html .text ] = 1
76
- } else {
77
- ++ computedElementalStorage[html .text ]
78
- }
69
+ ++ computedElementalStorage[html .text ]
79
70
}
80
71
}
81
72
}
82
- // invoke the recursive function
83
- checkChild (this .componentMap [this .activeComponent ].htmlList )
84
-
73
+ // invoke the recursive function
74
+ checkHtmlElements (this .componentMap [this .activeComponent ].htmlList )
85
75
} else if (this .activeComponent === " " ) {
86
76
// if component was switched from existing component to '', reset cache and update items
87
77
if (computedElementalStorage !== {}) computedElementalStorage = {};
@@ -95,9 +85,9 @@ export default {
95
85
}
96
86
return computedElementalStorage;
97
87
},
88
+ // Compute Child Components of the activeComponent to include them as icons
98
89
childrenComp : function () {
99
90
let childrenAvailable = [];
100
-
101
91
if (this .activeComponent ) {
102
92
childrenAvailable = this .componentMap [this .activeComponent ].children
103
93
}
0 commit comments