@@ -51,6 +51,7 @@ import {
51
51
get_descriptor ,
52
52
get_descriptors ,
53
53
is_array ,
54
+ is_function ,
54
55
object_assign ,
55
56
object_keys
56
57
} from './utils.js' ;
@@ -2524,6 +2525,8 @@ export function spread_dynamic_element_attributes(node, prev, attrs, css_hash) {
2524
2525
}
2525
2526
2526
2527
/**
2528
+ * The proxy handler for rest props (i.e. `const { x, ...rest } = $props()`).
2529
+ * Is passed the full `$$props` object and excludes the named props.
2527
2530
* @type {ProxyHandler<{ props: Record<string | symbol, unknown>, exclude: Array<string | symbol> }> }}
2528
2531
*/
2529
2532
const rest_props_handler = {
@@ -2567,6 +2570,9 @@ export function rest_props(props, rest) {
2567
2570
}
2568
2571
2569
2572
/**
2573
+ * The proxy handler for spread props. Handles the incoming array of props
2574
+ * that looks like `() => { dynamic: props }, { static: prop }, ..` and wraps
2575
+ * them so that the whole thing is passed to the component as the `$$props` argument.
2570
2576
* @template {Record<string | symbol, unknown>} T
2571
2577
* @type {ProxyHandler<{ props: Array<T | (() => T)> }> }}
2572
2578
*/
@@ -2575,7 +2581,7 @@ const spread_props_handler = {
2575
2581
let i = target . props . length ;
2576
2582
while ( i -- ) {
2577
2583
let p = target . props [ i ] ;
2578
- if ( typeof p === 'function' ) p = p ( ) ;
2584
+ if ( is_function ( p ) ) p = p ( ) ;
2579
2585
if ( typeof p === 'object' && p !== null && key in p ) return p [ key ] ;
2580
2586
}
2581
2587
} ,
@@ -2584,7 +2590,7 @@ const spread_props_handler = {
2584
2590
} ,
2585
2591
has ( target , key ) {
2586
2592
for ( let p of target . props ) {
2587
- if ( typeof p === 'function' ) p = p ( ) ;
2593
+ if ( is_function ( p ) ) p = p ( ) ;
2588
2594
if ( key in p ) return true ;
2589
2595
}
2590
2596
@@ -2595,7 +2601,7 @@ const spread_props_handler = {
2595
2601
const keys = [ ] ;
2596
2602
2597
2603
for ( let p of target . props ) {
2598
- if ( typeof p === 'function' ) p = p ( ) ;
2604
+ if ( is_function ( p ) ) p = p ( ) ;
2599
2605
for ( const key in p ) {
2600
2606
if ( ! keys . includes ( key ) ) keys . push ( key ) ;
2601
2607
}
0 commit comments