@@ -248,10 +248,8 @@ export function setupComponentsBridgeEvents (bridge) {
248
248
const instance = componentsMap [ instanceId ]
249
249
if ( instance ) {
250
250
for ( const item of data ) {
251
- const component = componentsMap [ item . id ]
252
- for ( const key in item ) {
253
- Vue . set ( component , key , item [ key ] )
254
- }
251
+ restoreChildrenFromComponentsMap ( item )
252
+ const component = updateComponentsMapData ( item )
255
253
addToComponentsMap ( component )
256
254
}
257
255
} else if ( Array . isArray ( data ) ) {
@@ -300,6 +298,27 @@ function requestComponentTree (instanceId = null) {
300
298
} )
301
299
}
302
300
301
+ function restoreChildrenFromComponentsMap ( data ) {
302
+ const instance = componentsMap [ data . id ]
303
+ if ( instance && data . hasChildren ) {
304
+ if ( ! data . children . length && instance . children . length ) {
305
+ data . children = instance . children
306
+ } else {
307
+ for ( const child of data . children ) {
308
+ restoreChildrenFromComponentsMap ( child )
309
+ }
310
+ }
311
+ }
312
+ }
313
+
314
+ function updateComponentsMapData ( data ) {
315
+ const component = componentsMap [ data . id ]
316
+ for ( const key in data ) {
317
+ Vue . set ( component , key , data [ key ] )
318
+ }
319
+ return component
320
+ }
321
+
303
322
function addToComponentsMap ( instance ) {
304
323
componentsMap [ instance . id ] = instance
305
324
if ( instance . children ) {
0 commit comments