@@ -209,8 +209,27 @@ const mutations = {
209
209
// //add binding
210
210
[ types . addBindingText ] : ( state , payload ) => {
211
211
//access the htmlList, add payload to the empty bind obj
212
- //state.component
213
- console . log ( state . componentMap [ state . activeComponent ] )
212
+ //const active = state.componentMap[state.activeComponent].htmlList;
213
+ if ( payload === "" ) {
214
+ state . componentMap = {
215
+ ...state . componentMap
216
+ }
217
+ } else {
218
+ const id = payload . id
219
+ state . componentMap [ state . activeComponentObj ] . htmlList . forEach ( ( el ) => {
220
+
221
+ if ( el . children . length !== 0 ) {
222
+ el . children . forEach ( ( element ) => {
223
+ if ( payload . id === element . id ) {
224
+ element . binding = payload . binding
225
+ }
226
+ } )
227
+ }
228
+ if ( payload . id === el . id ) {
229
+ el . binding = payload . binding
230
+ }
231
+ } )
232
+ }
214
233
} ,
215
234
[ types . DELETE_ACTION_FROM_COMPONENT ] : ( state , payload ) => {
216
235
state . componentMap [ state . activeComponent ] . actions = state . componentMap [ state . activeComponent ] . actions . filter (
@@ -807,12 +826,23 @@ const mutations = {
807
826
} ,
808
827
809
828
[ types . ADD_ACTIVE_COMPONENT_CLASS ] : ( state , payload ) => {
810
- state . componentMap [ state . activeComponent ] . htmlList . forEach ( ( el ) => {
811
- if ( payload . id === el . id ) {
812
- el . class = payload . class
813
- }
814
- } )
829
+ if ( state . activeComponentObj . htmlList )
830
+ state . componentMap [ state . activeComponent ] . htmlList . forEach ( ( el ) => {
831
+ //adding class into it's child 1st layer
832
+ if ( el . children . length !== 0 ) {
833
+ el . children . forEach ( ( element ) => {
834
+ if ( payload . id === element . id ) {
835
+ element . class = payload . class
836
+ }
837
+ } )
838
+ }
839
+ if ( payload . id === el . id ) {
840
+ el . class = payload . class
841
+ }
842
+ } )
815
843
} ,
844
+
845
+
816
846
[ types . DELETE_ACTIVE_COMPONENT_CLASS ] : ( state , payload ) => {
817
847
state . componentMap [ state . activeComponent ] . classList . forEach ( ( el , ind ) => {
818
848
if ( payload === el ) {
0 commit comments