@@ -83,25 +83,6 @@ export function getDomContainerFromQContainerElement(qContainerElement: Element)
83
83
let container = qElement . qContainer ;
84
84
if ( ! container ) {
85
85
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 ;
105
86
}
106
87
return container ;
107
88
}
@@ -163,22 +144,23 @@ export class DomContainer extends _SharedContainer implements IClientContainer {
163
144
this . $instanceHash$ = element . getAttribute ( QInstanceAttr ) ! ;
164
145
this . qManifestHash = element . getAttribute ( QManifestHashAttr ) ! ;
165
146
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$ = [ ] ;
169
149
const document = this . element . ownerDocument as QDocument ;
170
150
if ( ! document . qVNodeData ) {
171
151
processVNodeData ( document ) ;
172
152
}
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
+
175
158
const qwikStates = element . querySelectorAll ( 'script[type="qwik/state"]' ) ;
176
159
if ( qwikStates . length !== 0 ) {
177
160
const lastState = qwikStates [ qwikStates . length - 1 ] ;
178
161
this . $rawStateData$ = JSON . parse ( lastState . textContent ! ) ;
179
162
this . $stateData$ = wrapDeserializerProxy ( this , this . $rawStateData$ ) as unknown [ ] ;
180
163
}
181
- this . $qFuncs$ = getQFuncs ( document , this . $instanceHash$ ) || EMPTY_ARRAY ;
182
164
}
183
165
184
166
$setRawState$ ( id : number , vParent : ElementVNode | VirtualVNode ) : void {
@@ -372,4 +354,21 @@ export class DomContainer extends _SharedContainer implements IClientContainer {
372
354
this . $journal$ . push ( VNodeJournalOpCode . Insert , this . document . head , null , styleElement ) ;
373
355
}
374
356
}
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
+ }
375
374
}
0 commit comments