@@ -403,6 +403,35 @@ const global_visitors = {
403
403
}
404
404
405
405
return next ( ) ;
406
+ } ,
407
+ CallExpression ( node , context ) {
408
+ const rune = get_rune ( node , context . state . scope ) ;
409
+
410
+ if ( rune === '$host' ) {
411
+ return b . id ( 'undefined' ) ;
412
+ }
413
+
414
+ if ( rune === '$effect.active' ) {
415
+ return b . literal ( false ) ;
416
+ }
417
+
418
+ if ( rune === '$state.snapshot' ) {
419
+ return /** @type {import('estree').Expression } */ ( context . visit ( node . arguments [ 0 ] ) ) ;
420
+ }
421
+
422
+ if ( rune === '$state.is' ) {
423
+ return b . call (
424
+ 'Object.is' ,
425
+ /** @type {import('estree').Expression } */ ( context . visit ( node . arguments [ 0 ] ) ) ,
426
+ /** @type {import('estree').Expression } */ ( context . visit ( node . arguments [ 1 ] ) )
427
+ ) ;
428
+ }
429
+
430
+ if ( rune === '$inspect' || rune === '$inspect().with' ) {
431
+ return transform_inspect_rune ( node , context ) ;
432
+ }
433
+
434
+ context . next ( ) ;
406
435
}
407
436
} ;
408
437
@@ -625,35 +654,6 @@ const javascript_visitors_runes = {
625
654
}
626
655
context . next ( ) ;
627
656
} ,
628
- CallExpression ( node , context ) {
629
- const rune = get_rune ( node , context . state . scope ) ;
630
-
631
- if ( rune === '$host' ) {
632
- return b . id ( 'undefined' ) ;
633
- }
634
-
635
- if ( rune === '$effect.active' ) {
636
- return b . literal ( false ) ;
637
- }
638
-
639
- if ( rune === '$state.snapshot' ) {
640
- return /** @type {import('estree').Expression } */ ( context . visit ( node . arguments [ 0 ] ) ) ;
641
- }
642
-
643
- if ( rune === '$state.is' ) {
644
- return b . call (
645
- 'Object.is' ,
646
- /** @type {import('estree').Expression } */ ( context . visit ( node . arguments [ 0 ] ) ) ,
647
- /** @type {import('estree').Expression } */ ( context . visit ( node . arguments [ 1 ] ) )
648
- ) ;
649
- }
650
-
651
- if ( rune === '$inspect' || rune === '$inspect().with' ) {
652
- return transform_inspect_rune ( node , context ) ;
653
- }
654
-
655
- context . next ( ) ;
656
- } ,
657
657
MemberExpression ( node , context ) {
658
658
if ( node . object . type === 'ThisExpression' && node . property . type === 'PrivateIdentifier' ) {
659
659
const field = context . state . private_derived . get ( node . property . name ) ;
@@ -1548,6 +1548,7 @@ const template_visitors = {
1548
1548
spreads . push ( /** @type {import('estree').Expression } */ ( context . visit ( attribute ) ) ) ;
1549
1549
} else if ( attribute . type === 'Attribute' ) {
1550
1550
const value = serialize_attribute_value ( attribute . value , context , false , true ) ;
1551
+
1551
1552
if ( attribute . name === 'name' ) {
1552
1553
expression = b . member ( b . member_id ( '$$props.$$slots' ) , value , true , true ) ;
1553
1554
} else if ( attribute . name !== 'slot' ) {
@@ -1585,9 +1586,7 @@ const template_visitors = {
1585
1586
context . state . template . push (
1586
1587
b . stmt ( b . call ( '$.head' , b . id ( '$$payload' ) , b . arrow ( [ b . id ( '$$payload' ) ] , block ) ) )
1587
1588
) ;
1588
- } ,
1589
- // @ts -ignore: need to extract this out somehow
1590
- CallExpression : javascript_visitors_runes . CallExpression
1589
+ }
1591
1590
} ;
1592
1591
1593
1592
/**
@@ -1614,8 +1613,8 @@ function serialize_element_attributes(node, context) {
1614
1613
1615
1614
let has_spread = false ;
1616
1615
// Use the index to keep the attributes order which is important for spreading
1617
- let class_attribute_idx = - 1 ;
1618
- let style_attribute_idx = - 1 ;
1616
+ let class_index = - 1 ;
1617
+ let style_index = - 1 ;
1619
1618
let events_to_capture = new Set ( ) ;
1620
1619
1621
1620
for ( const attribute of node . attributes ) {
@@ -1649,9 +1648,9 @@ function serialize_element_attributes(node, context) {
1649
1648
}
1650
1649
} else {
1651
1650
if ( attribute . name === 'class' ) {
1652
- class_attribute_idx = attributes . length ;
1651
+ class_index = attributes . length ;
1653
1652
} else if ( attribute . name === 'style' ) {
1654
- style_attribute_idx = attributes . length ;
1653
+ style_index = attributes . length ;
1655
1654
}
1656
1655
attributes . push ( attribute ) ;
1657
1656
}
@@ -1761,21 +1760,21 @@ function serialize_element_attributes(node, context) {
1761
1760
if ( class_directives . length > 0 && ! has_spread ) {
1762
1761
const class_attribute = serialize_class_directives (
1763
1762
class_directives ,
1764
- /** @type {import('#compiler').Attribute | null } */ ( attributes [ class_attribute_idx ] ?? null )
1763
+ /** @type {import('#compiler').Attribute | null } */ ( attributes [ class_index ] ?? null )
1765
1764
) ;
1766
- if ( class_attribute_idx === - 1 ) {
1765
+ if ( class_index === - 1 ) {
1767
1766
attributes . push ( class_attribute ) ;
1768
1767
}
1769
1768
}
1770
1769
1771
1770
if ( style_directives . length > 0 && ! has_spread ) {
1772
1771
serialize_style_directives (
1773
1772
style_directives ,
1774
- /** @type {import('#compiler').Attribute | null } */ ( attributes [ style_attribute_idx ] ?? null ) ,
1773
+ /** @type {import('#compiler').Attribute | null } */ ( attributes [ style_index ] ?? null ) ,
1775
1774
context
1776
1775
) ;
1777
- if ( style_attribute_idx > - 1 ) {
1778
- attributes . splice ( style_attribute_idx , 1 ) ;
1776
+ if ( style_index > - 1 ) {
1777
+ attributes . splice ( style_index , 1 ) ;
1779
1778
}
1780
1779
}
1781
1780
0 commit comments