@@ -350,8 +350,6 @@ class SSRContainer extends _SharedContainer implements ISSRContainer {
350350 openContainer ( ) {
351351 if ( this . tag == 'html' ) {
352352 this . write ( '<!DOCTYPE html>' ) ;
353- // -1 so we only emit inside body
354- this . $noScriptHere$ = - 1 ;
355353 }
356354
357355 const containerAttributes = this . renderOptions . containerAttributes || { } ;
@@ -383,7 +381,6 @@ class SSRContainer extends _SharedContainer implements ISSRContainer {
383381 return this . closeElement ( ) ;
384382 }
385383
386- // -1 so we only emit inside body
387384 private $noScriptHere$ : number = 0 ;
388385
389386 /** Renders opening tag for DOM element */
@@ -393,21 +390,27 @@ class SSRContainer extends _SharedContainer implements ISSRContainer {
393390 constAttrs ?: SsrAttrs | null ,
394391 currentFile ?: string | null
395392 ) : string | undefined {
396- if ( this . qlInclude === QwikLoaderInclude . Inline ) {
397- if ( this . $noScriptHere$ === 0 && this . size > 30 * 1024 ) {
393+ const isQwikStyle =
394+ isQwikStyleElement ( elementName , varAttrs ) || isQwikStyleElement ( elementName , constAttrs ) ;
395+
396+ if (
397+ // don't append qwik loader before qwik style elements
398+ // it will confuse the resuming, because styles are expected to be the first nodes in subtree
399+ ! isQwikStyle &&
400+ this . qlInclude === QwikLoaderInclude . Inline
401+ ) {
402+ if ( this . $noScriptHere$ === 0 && this . size > 30 * 1024 && elementName !== 'body' ) {
398403 // We waited long enough, on slow connections the page is already partially visible
399404 this . emitQwikLoaderInline ( ) ;
400405 }
401406 // keep track of noscript and template, and for html we only emit inside body
402- else if ( elementName === 'noscript' || elementName === 'template' || elementName === 'body' ) {
407+ else if ( elementName === 'noscript' || elementName === 'template' ) {
403408 this . $noScriptHere$ ++ ;
404409 }
405410 }
406411
407412 let innerHTML : string | undefined = undefined ;
408413 this . lastNode = null ;
409- const isQwikStyle =
410- isQwikStyleElement ( elementName , varAttrs ) || isQwikStyleElement ( elementName , constAttrs ) ;
411414 if ( ! isQwikStyle && this . currentElementFrame ) {
412415 vNodeData_incrementElementCount ( this . currentElementFrame . vNodeData ) ;
413416 }
0 commit comments