File tree Expand file tree Collapse file tree
packages/qwik/src/core/client Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -108,6 +108,20 @@ export const processContainerData = (container: IClientContainer): void => {
108108 ) {
109109 return ;
110110 }
111+ if (
112+ ! domContainer . element . querySelector ( 'script[type="qwik/state"]' ) &&
113+ ! domContainer . document . body . querySelector ( QStylesAllSelector )
114+ ) {
115+ try {
116+ runIteratorSync ( domContainer . $processContainerData$ ( ) ) ;
117+ markContainerDataReady ( domContainer ) ;
118+ } catch ( error ) {
119+ domContainer . $containerDataStarted$ = false ;
120+ domContainer . $containerDataState$ = undefined ;
121+ throw error ;
122+ }
123+ return ;
124+ }
111125 const state : ProcessContainerDataState = {
112126 $iterator$ : domContainer . $processContainerData$ ( ) ,
113127 $schedule$ : undefined ! ,
@@ -131,6 +145,15 @@ export const processContainerData = (container: IClientContainer): void => {
131145 } ) ;
132146} ;
133147
148+ function runIteratorSync < T > ( iterator : Generator < void , T , void > ) : T {
149+ while ( true ) {
150+ const result = iterator . next ( ) ;
151+ if ( result . done ) {
152+ return result . value ;
153+ }
154+ }
155+ }
156+
134157export const onContainerDataReady = ( container : IClientContainer , callback : ( ) => void ) : void => {
135158 const domContainer = container as DomContainer ;
136159 if ( domContainer . $containerDataReady$ ) {
Original file line number Diff line number Diff line change @@ -94,6 +94,10 @@ export function processVNodeData(document: Document): void {
9494 }
9595 qDocument . qVNodeDataStarted = true ;
9696 qDocument . qVNodeData || ( qDocument . qVNodeData = new WeakMap < Element , string > ( ) ) ;
97+ if ( ! document . querySelector ( 'script[type="qwik/vnode"], [q\\:shadowroot]' ) ) {
98+ markVNodeDataReady ( qDocument ) ;
99+ return ;
100+ }
97101 const state : ProcessVNodeDataState = {
98102 $document$ : qDocument ,
99103 $iterator$ : processVNodeDataIterator ( document ) ,
Original file line number Diff line number Diff line change @@ -12,6 +12,19 @@ import { Fragment } from '@qwik.dev/core';
1212import { TypeIds } from '../shared/serdes/constants' ;
1313
1414describe ( 'processVnodeData' , ( ) => {
15+ it ( 'should finish empty container data without scheduling a chunk' , async ( ) => {
16+ const document = createDocument ( ) as QDocument ;
17+ document . body . setAttribute ( QContainerAttr , QContainerValue . RESUMED ) ;
18+
19+ await withYieldingVNodeData ( document , async ( tasks ) => {
20+ const container = getDomContainer ( document . body ) as any ;
21+
22+ expect ( document . qVNodeDataReady ) . toBe ( true ) ;
23+ expect ( container . $containerDataReady$ ) . toBe ( true ) ;
24+ expect ( tasks ) . toHaveLength ( 0 ) ;
25+ } ) ;
26+ } ) ;
27+
1528 it ( 'should yield over multiple chunks and preserve vnode data and refs' , async ( ) => {
1629 const document = createDocument ( {
1730 html : `
You can’t perform that action at this time.
0 commit comments