@@ -5,7 +5,13 @@ import { Fragment, directGetPropsProxyProp } from '../shared/jsx/jsx-runtime';
5
5
import { Slot } from '../shared/jsx/slot.public' ;
6
6
import type { JSXNodeInternal , JSXOutput } from '../shared/jsx/types/jsx-node' ;
7
7
import type { JSXChildren } from '../shared/jsx/types/jsx-qwik-attributes' ;
8
- import { SSRComment , SSRRaw , SSRStream , type SSRStreamChildren } from '../shared/jsx/utils.public' ;
8
+ import {
9
+ SSRBackpatch ,
10
+ SSRComment ,
11
+ SSRRaw ,
12
+ SSRStream ,
13
+ type SSRStreamChildren ,
14
+ } from '../shared/jsx/utils.public' ;
9
15
import { createQRL , type QRLInternal } from '../shared/qrl/qrl-class' ;
10
16
import type { QRL } from '../shared/qrl/qrl.public' ;
11
17
import { qrlToString , type SerializationContext } from '../shared/shared-serialization' ;
@@ -245,13 +251,7 @@ function processJSXNode(
245
251
ssr . closeFragment ( ) ;
246
252
}
247
253
} else if ( type === SSRComment ) {
248
- const commentData = directGetPropsProxyProp ( jsx , 'data' ) || '' ;
249
- const commentContent = String ( commentData ) ;
250
- if ( commentContent . startsWith ( 'qwik:backpatch' ) ) {
251
- ssr . commentNode ( handleBackpatchComment ( ssr , commentContent ) ) ;
252
- } else {
253
- ssr . commentNode ( commentContent ) ;
254
- }
254
+ ssr . commentNode ( directGetPropsProxyProp ( jsx , 'data' ) || '' ) ;
255
255
} else if ( type === SSRStream ) {
256
256
ssr . commentNode ( FLUSH_COMMENT ) ;
257
257
const generator = jsx . children as SSRStreamChildren ;
@@ -274,6 +274,18 @@ function processJSXNode(
274
274
isPromise ( value ) && enqueue ( Promise ) ;
275
275
} else if ( type === SSRRaw ) {
276
276
ssr . htmlNode ( directGetPropsProxyProp ( jsx , 'data' ) ) ;
277
+ } else if ( type === SSRBackpatch ) {
278
+ const backpatchScopeId = getNextUniqueIndex ( ssr ) ;
279
+ ssr . enterBackpatchScope ?.( backpatchScopeId ) ;
280
+
281
+ enqueue ( ( ) => {
282
+ if ( ssr . currentBackpatchScope === backpatchScopeId ) {
283
+ ssr . exitBackpatchScope ?.( backpatchScopeId ) ;
284
+ }
285
+ } ) ;
286
+
287
+ const children = jsx . children as JSXOutput ;
288
+ children != null && enqueue ( children ) ;
277
289
} else if ( isQwikComponent ( type ) ) {
278
290
// prod: use new instance of an array for props, we always modify props for a component
279
291
ssr . openComponent ( isDev ? [ DEBUG_TYPE , VirtualType . Component ] : [ ] ) ;
@@ -554,18 +566,3 @@ function appendClassIfScopedStyleExists(jsx: JSXNodeInternal, styleScoped: strin
554
566
jsx . constProps [ 'class' ] = '' ;
555
567
}
556
568
}
557
-
558
- function handleBackpatchComment ( ssr : SSRContainer , commentContent : string ) : string {
559
- if ( commentContent === 'qwik:backpatch:start' ) {
560
- const backpatchScopeId = getNextUniqueIndex ( ssr ) ;
561
- ssr . enterBackpatchScope ?.( backpatchScopeId ) ;
562
- return `${ commentContent } :${ backpatchScopeId } ` ;
563
- } else if ( commentContent === 'qwik:backpatch:end' ) {
564
- const currentBackpatchScope = ssr . currentBackpatchScope ;
565
- if ( currentBackpatchScope ) {
566
- ssr . exitBackpatchScope ?.( currentBackpatchScope ) ;
567
- }
568
- return commentContent ;
569
- }
570
- return commentContent ;
571
- }
0 commit comments