@@ -25,7 +25,6 @@ import {
25
25
QLocaleAttr ,
26
26
QManifestHashAttr ,
27
27
QScopedStyle ,
28
- QSlotParent ,
29
28
QStyle ,
30
29
QStyleSelector ,
31
30
Q_PROPS_SEPARATOR ,
@@ -42,32 +41,26 @@ import type { ContextId } from '../use/use-context';
42
41
import { processVNodeData } from './process-vnode-data' ;
43
42
import {
44
43
VNodeFlags ,
45
- VNodeProps ,
46
44
type ContainerElement ,
47
- type ElementVNode ,
48
45
type ClientContainer as IClientContainer ,
49
46
type QDocument ,
50
- type VNode ,
51
- type VirtualVNode ,
52
47
} from './types' ;
53
48
import { mapArray_get , mapArray_has , mapArray_set } from './util-mapArray' ;
54
49
import {
55
50
VNodeJournalOpCode ,
56
51
vnode_applyJournal ,
57
52
vnode_createErrorDiv ,
58
53
vnode_getDomParent ,
59
- vnode_getNextSibling ,
60
- vnode_getParent ,
61
- vnode_getProp ,
62
54
vnode_getProps ,
63
55
vnode_insertBefore ,
64
56
vnode_isElementVNode ,
57
+ vnode_isVNode ,
65
58
vnode_isVirtualVNode ,
66
59
vnode_locate ,
67
60
vnode_newUnMaterializedElement ,
68
- vnode_setProp ,
69
61
type VNodeJournal ,
70
62
} from './vnode' ;
63
+ import type { ElementVNode , VirtualVNode , VNode } from './vnode-impl' ;
71
64
72
65
/** @public */
73
66
export function getDomContainer ( element : Element | VNode ) : IClientContainer {
@@ -89,7 +82,7 @@ export function getDomContainerFromQContainerElement(qContainerElement: Element)
89
82
90
83
/** @internal */
91
84
export function _getQContainerElement ( element : Element | VNode ) : Element | null {
92
- const qContainerElement : Element | null = Array . isArray ( element )
85
+ const qContainerElement : Element | null = vnode_isVNode ( element )
93
86
? ( vnode_getDomParent ( element , true ) as Element )
94
87
: element ;
95
88
return qContainerElement . closest ( QContainerSelector ) ;
@@ -175,13 +168,13 @@ export class DomContainer extends _SharedContainer implements IClientContainer {
175
168
return inflateQRL ( this , parseQRL ( qrl ) ) as QRL < T > ;
176
169
}
177
170
178
- handleError ( err : any , host : HostElement | null ) : void {
171
+ handleError ( err : any , host : VNode | null ) : void {
179
172
if ( qDev && host ) {
180
173
if ( typeof document !== 'undefined' ) {
181
174
const vHost = host as VirtualVNode ;
182
175
const journal : VNodeJournal = [ ] ;
183
- const vHostParent = vnode_getParent ( vHost ) as VirtualVNode | ElementVNode | undefined ;
184
- const vHostNextSibling = vnode_getNextSibling ( vHost ) ;
176
+ const vHostParent = vHost . parent ;
177
+ const vHostNextSibling = vHost . nextSibling as VNode | null ;
185
178
const vErrorDiv = vnode_createErrorDiv ( document , vHost , err , journal ) ;
186
179
// If the host is an element node, we need to insert the error div into its parent.
187
180
const insertHost = vnode_isElementVNode ( vHost ) ? vHostParent || vHost : vHost ;
@@ -207,15 +200,15 @@ export class DomContainer extends _SharedContainer implements IClientContainer {
207
200
errorStore . error = err ;
208
201
}
209
202
210
- setContext < T > ( host : HostElement , context : ContextId < T > , value : T ) : void {
203
+ setContext < T > ( host : VNode , context : ContextId < T > , value : T ) : void {
211
204
let ctx = this . getHostProp < Array < string | unknown > > ( host , QCtxAttr ) ;
212
205
if ( ctx == null ) {
213
206
this . setHostProp ( host , QCtxAttr , ( ctx = [ ] ) ) ;
214
207
}
215
208
mapArray_set ( ctx , context . id , value , 0 , true ) ;
216
209
}
217
210
218
- resolveContext < T > ( host : HostElement , contextId : ContextId < T > ) : T | undefined {
211
+ resolveContext < T > ( host : VNode , contextId : ContextId < T > ) : T | undefined {
219
212
while ( host ) {
220
213
const ctx = this . getHostProp < Array < string | unknown > > ( host , QCtxAttr ) ;
221
214
if ( ctx != null && mapArray_has ( ctx , contextId . id , 0 ) ) {
@@ -226,27 +219,27 @@ export class DomContainer extends _SharedContainer implements IClientContainer {
226
219
return undefined ;
227
220
}
228
221
229
- getParentHost ( host : HostElement ) : HostElement | null {
230
- let vNode = vnode_getParent ( host as any ) ;
222
+ getParentHost ( host : VNode ) : VNode | null {
223
+ let vNode : VNode | null = host . parent ;
231
224
while ( vNode ) {
232
225
if ( vnode_isVirtualVNode ( vNode ) ) {
233
- if ( vnode_getProp ( vNode , OnRenderProp , null ) !== null ) {
234
- return vNode as any as HostElement ;
226
+ if ( vNode . getProp ( OnRenderProp , null ) !== null ) {
227
+ return vNode ;
235
228
}
236
229
vNode =
237
- vnode_getParent ( vNode ) ||
230
+ vNode . parent ||
238
231
// If virtual node, than it could be a slot so we need to read its parent.
239
- vnode_getProp < VNode > ( vNode , QSlotParent , this . vNodeLocate ) ;
232
+ vNode . slotParent ;
240
233
} else {
241
- vNode = vnode_getParent ( vNode ) ;
234
+ vNode = vNode . parent ;
242
235
}
243
236
}
244
237
return null ;
245
238
}
246
239
247
240
setHostProp < T > ( host : HostElement , name : string , value : T ) : void {
248
241
const vNode : VirtualVNode = host as any ;
249
- vnode_setProp ( vNode , name , value ) ;
242
+ vNode . setProp ( name , value ) ;
250
243
}
251
244
252
245
getHostProp < T > ( host : HostElement , name : string ) : T | null {
@@ -265,12 +258,12 @@ export class DomContainer extends _SharedContainer implements IClientContainer {
265
258
getObjectById = parseInt ;
266
259
break ;
267
260
}
268
- return vnode_getProp ( vNode , name , getObjectById ) ;
261
+ return vNode . getProp ( name , getObjectById ) ;
269
262
}
270
263
271
264
ensureProjectionResolved ( vNode : VirtualVNode ) : void {
272
- if ( ( vNode [ VNodeProps . flags ] & VNodeFlags . Resolved ) === 0 ) {
273
- vNode [ VNodeProps . flags ] |= VNodeFlags . Resolved ;
265
+ if ( ( vNode . flags & VNodeFlags . Resolved ) === 0 ) {
266
+ vNode . flags |= VNodeFlags . Resolved ;
274
267
const props = vnode_getProps ( vNode ) ;
275
268
for ( let i = 0 ; i < props . length ; i = i + 2 ) {
276
269
const prop = props [ i ] as string ;
@@ -279,7 +272,6 @@ export class DomContainer extends _SharedContainer implements IClientContainer {
279
272
if ( typeof value == 'string' ) {
280
273
const projection = this . vNodeLocate ( value ) ;
281
274
props [ i + 1 ] = projection ;
282
- vnode_getProp ( projection , QSlotParent , ( id ) => this . vNodeLocate ( id ) ) ;
283
275
}
284
276
}
285
277
}
0 commit comments