File tree Expand file tree Collapse file tree 5 files changed +31
-3
lines changed
src/compiler/phases/3-transform/client/visitors
tests/runtime-runes/samples/dynamic-component-nested Expand file tree Collapse file tree 5 files changed +31
-3
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' svelte ' : patch
3+ ---
4+
5+ fix: avoid shadowing a variable in dynamic components
Original file line number Diff line number Diff line change @@ -10,9 +10,10 @@ import { build_component } from './shared/component.js';
1010export function Component ( node , context ) {
1111 const component = build_component (
1212 node ,
13- // if it's not dynamic we will just use the node name, if it is dynamic we will use the node name
14- // only if it's a valid identifier, otherwise we will use a default name
15- ! node . metadata . dynamic || regex_is_valid_identifier . test ( node . name ) ? node . name : '$$component' ,
13+ // avoid shadowing the component variable by a variable used in $.component
14+ node . metadata . dynamic
15+ ? '$$component_' + node . name . replaceAll ( / [ ^ a - z A - Z _ $ 0 - 9 ] / g, '_' )
16+ : node . name ,
1617 context
1718 ) ;
1819 context . state . init . push ( component ) ;
Original file line number Diff line number Diff line change 1+ <script >
2+ const { children } = $props ()
3+ </script >
4+
5+ {@render children ()}
Original file line number Diff line number Diff line change 1+ import { test } from '../../test' ;
2+ import { flushSync } from 'svelte' ;
3+
4+ export default test ( {
5+ async test ( { assert, target } ) {
6+ assert . htmlEqual ( target . innerHTML , 'test' ) ;
7+ }
8+ } ) ;
Original file line number Diff line number Diff line change 1+ <script >
2+ import A from ' ./A.svelte' ;
3+
4+ const B = $derived (A );
5+ </script >
6+
7+ <B >
8+ <B >test</B >
9+ </B >
You can’t perform that action at this time.
0 commit comments