@@ -227,6 +227,80 @@ describe.each([
227
227
) ;
228
228
} ) ;
229
229
230
+ it ( 'should not rerender not changed component' , async ( ) => {
231
+ ( globalThis as any ) . componentExecuted = [ ] ;
232
+ const Component1 = component$ ( ( ) => {
233
+ ( globalThis as any ) . componentExecuted . push ( 'Component1' ) ;
234
+ const signal1 = useSignal ( 1 ) ;
235
+ return (
236
+ < div >
237
+ < span > Component 1</ span >
238
+ { signal1 . value }
239
+ </ div >
240
+ ) ;
241
+ } ) ;
242
+ const Component2 = component$ ( ( ) => {
243
+ ( globalThis as any ) . componentExecuted . push ( 'Component2' ) ;
244
+ const signal2 = useSignal ( 2 ) ;
245
+ return (
246
+ < div >
247
+ < span > Component 2</ span >
248
+ { signal2 . value }
249
+ </ div >
250
+ ) ;
251
+ } ) ;
252
+ const Parent = component$ ( ( ) => {
253
+ ( globalThis as any ) . componentExecuted . push ( 'Parent' ) ;
254
+ const show = useSignal ( true ) ;
255
+ return (
256
+ < main class = "parent" onClick$ = { ( ) => ( show . value = false ) } >
257
+ { show . value && < Component1 /> }
258
+ < Component2 />
259
+ </ main >
260
+ ) ;
261
+ } ) ;
262
+ const { vNode, container } = await render ( < Parent /> , { debug } ) ;
263
+ expect ( vNode ) . toMatchVDOM (
264
+ < Component ssr-required >
265
+ < main class = "parent" >
266
+ < Component ssr-required >
267
+ < div >
268
+ < span > Component 1</ span >
269
+ < Signal ssr-required > 1</ Signal >
270
+ </ div >
271
+ </ Component >
272
+ < Component ssr-required >
273
+ < div >
274
+ < span > Component 2</ span >
275
+ < Signal ssr-required > 2</ Signal >
276
+ </ div >
277
+ </ Component >
278
+ </ main >
279
+ </ Component >
280
+ ) ;
281
+ expect ( ( globalThis as any ) . componentExecuted ) . toEqual ( [ 'Parent' , 'Component1' , 'Component2' ] ) ;
282
+ await trigger ( container . element , 'main.parent' , 'click' ) ;
283
+ expect ( ( globalThis as any ) . componentExecuted ) . toEqual ( [
284
+ 'Parent' ,
285
+ 'Component1' ,
286
+ 'Component2' ,
287
+ 'Parent' ,
288
+ ] ) ;
289
+ expect ( vNode ) . toMatchVDOM (
290
+ < Component ssr-required >
291
+ < main class = "parent" >
292
+ { '' }
293
+ < Component ssr-required >
294
+ < div >
295
+ < span > Component 2</ span >
296
+ < Signal ssr-required > 2</ Signal >
297
+ </ div >
298
+ </ Component >
299
+ </ main >
300
+ </ Component >
301
+ ) ;
302
+ } ) ;
303
+
230
304
it ( 'should remove children from component$' , async ( ) => {
231
305
const log : string [ ] = [ ] ;
232
306
const MyComp = component$ ( ( props : any ) => {
0 commit comments