File tree 4 files changed +40
-1
lines changed
4 files changed +40
-1
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @qwik.dev/core ' : patch
3
+ ---
4
+
5
+ fix: infinity loop while tracking element ref
Original file line number Diff line number Diff line change 1
1
import {
2
2
Fragment as Component ,
3
+ Fragment as Signal ,
3
4
component$ ,
4
5
createContextId ,
5
6
useContext ,
6
7
useContextProvider ,
7
8
useSignal ,
8
9
useStore ,
10
+ useTask$ ,
9
11
useVisibleTask$ ,
10
12
} from '@qwik.dev/core' ;
11
13
import { domRender , ssrRenderToDom , trigger } from '@qwik.dev/core/testing' ;
@@ -232,4 +234,34 @@ describe.each([
232
234
</ Component >
233
235
) ;
234
236
} ) ;
237
+
238
+ it ( 'should track element ref' , async ( ) => {
239
+ const Cmp = component$ ( ( ) => {
240
+ const element = useSignal < HTMLDivElement > ( ) ;
241
+ const signal = useSignal ( 0 ) ;
242
+
243
+ useTask$ ( ( { track } ) => {
244
+ track ( element ) ;
245
+ signal . value ++ ;
246
+ } ) ;
247
+
248
+ return (
249
+ < div >
250
+ < div ref = { element } > Test</ div >
251
+ { signal . value }
252
+ </ div >
253
+ ) ;
254
+ } ) ;
255
+
256
+ const { vNode } = await render ( < Cmp /> , { debug } ) ;
257
+
258
+ expect ( vNode ) . toMatchVDOM (
259
+ < Component >
260
+ < div >
261
+ < div > Test</ div >
262
+ < Signal > 1</ Signal >
263
+ </ div >
264
+ </ Component >
265
+ ) ;
266
+ } ) ;
235
267
} ) ;
Original file line number Diff line number Diff line change @@ -32,3 +32,4 @@ export type {
32
32
export type { ResolvedManifest , SymbolMapper } from '../optimizer/src/types' ;
33
33
export type { SymbolToChunkResolver } from '../core/ssr/ssr-types' ;
34
34
export type { NodePropData } from '../core/reactive-primitives/subscription-data' ;
35
+ export type { SignalImpl } from '../core/reactive-primitives/impl/signal-impl' ;
Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ import {
62
62
type JSXOutput ,
63
63
type QRLInternal ,
64
64
type SerializationContext ,
65
+ type SignalImpl ,
65
66
type SsrAttrKey ,
66
67
type SsrAttrValue ,
67
68
type SsrAttrs ,
@@ -1150,7 +1151,7 @@ class SSRContainer extends _SharedContainer implements ISSRContainer {
1150
1151
if ( key === 'ref' ) {
1151
1152
const lastNode = this . getLastNode ( ) ;
1152
1153
if ( isSignal ( value ) ) {
1153
- value . value = new DomRef ( lastNode ) ;
1154
+ ( value as SignalImpl < unknown > ) . $untrackedValue$ = new DomRef ( lastNode ) ;
1154
1155
continue ;
1155
1156
} else if ( typeof value === 'function' ) {
1156
1157
value ( new DomRef ( lastNode ) ) ;
You can’t perform that action at this time.
0 commit comments