@@ -19,11 +19,7 @@ function parseElements(raw_elements) {
19
19
) ;
20
20
}
21
21
22
- function replaceUndefinedAttributes ( elements , id ) {
23
- const element = elements [ id ] ;
24
- if ( element === undefined ) {
25
- return ;
26
- }
22
+ function replaceUndefinedAttributes ( element ) {
27
23
element . class ??= [ ] ;
28
24
element . style ??= { } ;
29
25
element . props ??= { } ;
@@ -35,7 +31,6 @@ function replaceUndefinedAttributes(elements, id) {
35
31
default : { ids : element . children || [ ] } ,
36
32
...( element . slots ?? { } ) ,
37
33
} ;
38
- Object . values ( element . slots ) . forEach ( ( slot ) => slot . ids . forEach ( ( id ) => replaceUndefinedAttributes ( elements , id ) ) ) ;
39
34
}
40
35
41
36
function getElement ( id ) {
@@ -318,7 +313,7 @@ window.onbeforeunload = function () {
318
313
} ;
319
314
320
315
function createApp ( elements , options ) {
321
- replaceUndefinedAttributes ( elements , 0 ) ;
316
+ Object . entries ( elements ) . forEach ( ( [ _ , element ] ) => replaceUndefinedAttributes ( element ) ) ;
322
317
setInterval ( ( ) => ack ( ) , 3000 ) ;
323
318
return ( app = Vue . createApp ( {
324
319
data ( ) {
@@ -381,16 +376,15 @@ function createApp(elements, options) {
381
376
const loadPromises = Object . entries ( msg )
382
377
. filter ( ( [ _ , element ] ) => element && ( element . component || element . libraries ) )
383
378
. map ( ( [ _ , element ] ) => loadDependencies ( element , options . prefix , options . version ) ) ;
384
-
385
379
await Promise . all ( loadPromises ) ;
386
380
387
381
for ( const [ id , element ] of Object . entries ( msg ) ) {
388
382
if ( element === null ) {
389
383
delete this . elements [ id ] ;
390
384
continue ;
391
385
}
386
+ replaceUndefinedAttributes ( element ) ;
392
387
this . elements [ id ] = element ;
393
- replaceUndefinedAttributes ( this . elements , id ) ;
394
388
}
395
389
} ,
396
390
run_javascript : ( msg ) => runJavascript ( msg . code , msg . request_id ) ,
0 commit comments