File tree Expand file tree Collapse file tree 3 files changed +40
-14
lines changed Expand file tree Collapse file tree 3 files changed +40
-14
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @qwik.dev/core ' : patch
3+ ---
4+
5+ fix: allow to modify inline component's children component props
Original file line number Diff line number Diff line change @@ -54,22 +54,17 @@ class PropsProxyHandler implements ProxyHandler<any> {
5454 prop = attr ;
5555 }
5656 }
57+
5758 if ( this . owner . constProps && prop in this . owner . constProps ) {
58- this . owner . constProps [ prop as string ] = undefined ;
59- if ( ! ( prop in this . owner . varProps ) ) {
60- this . owner . toSort = true ;
61- }
62- this . owner . varProps [ prop as string ] = value ;
63- } else {
64- if ( this . owner . varProps === EMPTY_OBJ ) {
65- this . owner . varProps = { } ;
66- } else {
67- if ( ! ( prop in this . owner . varProps ) ) {
68- this . owner . toSort = true ;
69- }
70- }
71- this . owner . varProps [ prop as string ] = value ;
59+ // delete the prop from the const props first
60+ delete this . owner . constProps [ prop as string ] ;
61+ }
62+ if ( this . owner . varProps === EMPTY_OBJ ) {
63+ this . owner . varProps = { } ;
64+ } else if ( ! ( prop in this . owner . varProps ) ) {
65+ this . owner . toSort = true ;
7266 }
67+ this . owner . varProps [ prop as string ] = value ;
7368 }
7469 return true ;
7570 }
Original file line number Diff line number Diff line change 88 useSignal ,
99 useStore ,
1010 useVisibleTask$ ,
11+ type FunctionComponent ,
1112 type PublicProps ,
1213} from '@qwik.dev/core' ;
1314import { domRender , ssrRenderToDom , trigger } from '@qwik.dev/core/testing' ;
@@ -691,4 +692,29 @@ describe.each([
691692 </ Component >
692693 ) ;
693694 } ) ;
695+
696+ it ( 'should allow to modify children component props' , async ( ) => {
697+ const Child = component$ ( ( props : { name : string } ) => {
698+ return < > { props . name } </ > ;
699+ } ) ;
700+
701+ const Parent : FunctionComponent = ( props ) => {
702+ ( props as any ) . children . props . name = 'World' ;
703+ return ( props as any ) . children ;
704+ } ;
705+
706+ const { vNode } = await render (
707+ < Parent >
708+ < Child name = "Hello" />
709+ </ Parent > ,
710+ { debug }
711+ ) ;
712+ expect ( vNode ) . toMatchVDOM (
713+ < InlineComponent >
714+ < Component >
715+ < Fragment > World</ Fragment >
716+ </ Component >
717+ </ InlineComponent >
718+ ) ;
719+ } ) ;
694720} ) ;
You can’t perform that action at this time.
0 commit comments