File tree Expand file tree Collapse file tree 5 files changed +51
-2
lines changed
tests/runtime-runes/samples/bind-and-spread Expand file tree Collapse file tree 5 files changed +51
-2
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' svelte ' : patch
3
+ ---
4
+
5
+ fix: take into account setters when spreading and binding
Original file line number Diff line number Diff line change @@ -2646,8 +2646,13 @@ const spread_props_handler = {
2646
2646
if ( typeof p === 'object' && p !== null && key in p ) return p [ key ] ;
2647
2647
}
2648
2648
} ,
2649
- getOwnPropertyDescriptor ( ) {
2650
- return { enumerable : true , configurable : true } ;
2649
+ getOwnPropertyDescriptor ( target , key ) {
2650
+ let i = target . props . length ;
2651
+ while ( i -- ) {
2652
+ let p = target . props [ i ] ;
2653
+ if ( is_function ( p ) ) p = p ( ) ;
2654
+ if ( typeof p === 'object' && p !== null && key in p ) return get_descriptor ( p , key ) ;
2655
+ }
2651
2656
} ,
2652
2657
has ( target , key ) {
2653
2658
for ( let p of target . props ) {
Original file line number Diff line number Diff line change
1
+ import { test } from '../../test' ;
2
+
3
+ export default test ( {
4
+ html : `<button class="foo">0</button><button class="foo">0</button>` ,
5
+
6
+ async test ( { assert, target } ) {
7
+ const [ btn1 , btn2 ] = target . querySelectorAll ( 'button' ) ;
8
+
9
+ await btn1 ?. click ( ) ;
10
+ assert . htmlEqual (
11
+ target . innerHTML ,
12
+ `<button class="foo">1</button><button class="foo">1</button>`
13
+ ) ;
14
+
15
+ await btn2 ?. click ( ) ;
16
+ assert . htmlEqual (
17
+ target . innerHTML ,
18
+ `<button class="foo">2</button><button class="foo">2</button>`
19
+ ) ;
20
+ }
21
+ } ) ;
Original file line number Diff line number Diff line change
1
+ <script >
2
+ let { value, ... props } = $props ();
3
+
4
+ </script >
5
+
6
+ <button {...props } onclick ={() => value ++ }>{value }</button >
Original file line number Diff line number Diff line change
1
+ <script >
2
+ import Button from ' ./button.svelte' ;
3
+
4
+ let value = $state (0 );
5
+
6
+ const props = {
7
+ class: ' foo'
8
+ };
9
+ </script >
10
+
11
+ <Button {...props } bind:value />
12
+ <button {...props } onclick ={() => value ++ }>{value }</button >
You can’t perform that action at this time.
0 commit comments