@@ -83,25 +83,6 @@ export function getDomContainerFromQContainerElement(qContainerElement: Element)
8383 let container = qElement . qContainer ;
8484 if ( ! container ) {
8585 container = new DomContainer ( qElement ) ;
86-
87- const containerAttributes : Record < string , string > = { } ;
88- if ( qElement ) {
89- const attrs = qElement . attributes ;
90- if ( attrs ) {
91- for ( let index = 0 ; index < attrs . length ; index ++ ) {
92- const attr = attrs [ index ] ;
93- if ( attr . name === Q_PROPS_SEPARATOR ) {
94- continue ;
95- }
96- containerAttributes [ attr . name ] = attr . value ;
97- }
98- }
99- }
100- ( container as DomContainer ) . $serverData$ = { containerAttributes } ;
101-
102- qElement . setAttribute ( QContainerAttr , QContainerValue . RESUMED ) ;
103-
104- qElement . qContainer = container ;
10586 }
10687 return container ;
10788}
@@ -163,22 +144,23 @@ export class DomContainer extends _SharedContainer implements IClientContainer {
163144 this . $instanceHash$ = element . getAttribute ( QInstanceAttr ) ! ;
164145 this . qManifestHash = element . getAttribute ( QManifestHashAttr ) ! ;
165146 this . rootVNode = vnode_newUnMaterializedElement ( this . element ) ;
166- // These are here to initialize all properties at once for single class transition
167- this . $rawStateData$ = null ! ;
168- this . $stateData$ = null ! ;
147+ this . $rawStateData$ = [ ] ;
148+ this . $stateData$ = [ ] ;
169149 const document = this . element . ownerDocument as QDocument ;
170150 if ( ! document . qVNodeData ) {
171151 processVNodeData ( document ) ;
172152 }
173- this . $rawStateData$ = [ ] ;
174- this . $stateData$ = [ ] ;
153+ this . $qFuncs$ = getQFuncs ( document , this . $instanceHash$ ) || EMPTY_ARRAY ;
154+ this . $setServerData$ ( ) ;
155+ element . setAttribute ( QContainerAttr , QContainerValue . RESUMED ) ;
156+ element . qContainer = this ;
157+
175158 const qwikStates = element . querySelectorAll ( 'script[type="qwik/state"]' ) ;
176159 if ( qwikStates . length !== 0 ) {
177160 const lastState = qwikStates [ qwikStates . length - 1 ] ;
178161 this . $rawStateData$ = JSON . parse ( lastState . textContent ! ) ;
179162 this . $stateData$ = wrapDeserializerProxy ( this , this . $rawStateData$ ) as unknown [ ] ;
180163 }
181- this . $qFuncs$ = getQFuncs ( document , this . $instanceHash$ ) || EMPTY_ARRAY ;
182164 }
183165
184166 $setRawState$ ( id : number , vParent : ElementVNode | VirtualVNode ) : void {
@@ -372,4 +354,21 @@ export class DomContainer extends _SharedContainer implements IClientContainer {
372354 this . $journal$ . push ( VNodeJournalOpCode . Insert , this . document . head , null , styleElement ) ;
373355 }
374356 }
357+
358+ // TODO: should be moved to the Qwik Router?
359+ /** Set the server data for the Qwik Router. */
360+ private $setServerData$ ( ) : void {
361+ const containerAttributes : Record < string , string > = { } ;
362+ const attrs = this . element . attributes ;
363+ if ( attrs ) {
364+ for ( let index = 0 ; index < attrs . length ; index ++ ) {
365+ const attr = attrs [ index ] ;
366+ if ( attr . name === Q_PROPS_SEPARATOR ) {
367+ continue ;
368+ }
369+ containerAttributes [ attr . name ] = attr . value ;
370+ }
371+ }
372+ this . $serverData$ = { containerAttributes } ;
373+ }
375374}
0 commit comments