@@ -102,17 +102,17 @@ export function processVNodeData(document: Document) {
102
102
///////////////////////////////
103
103
104
104
const enum NodeType {
105
- CONTAINER_MASK /* ***************** */ = 0b00000001 ,
106
- ELEMENT /* ************************ */ = 0b00000010 , // regular element
107
- ELEMENT_CONTAINER /* ************** */ = 0b00000011 , // container element need to descend into it
108
- ELEMENT_SHADOW_ROOT /* ************ */ = 0b00000110 , // shadow root element
109
- COMMENT_SKIP_START /* ************* */ = 0b00000101 , // Comment but skip the content until COMMENT_SKIP_END
110
- COMMENT_SKIP_END /* *************** */ = 0b00001000 , // Comment end
111
- COMMENT_IGNORE_START /* *********** */ = 0b00010000 , // Comment ignore, descend into children and skip the content until COMMENT_ISLAND_START
112
- COMMENT_IGNORE_END /* ************* */ = 0b00100000 , // Comment ignore end
113
- COMMENT_ISLAND_START /* *********** */ = 0b01000001 , // Comment island, count elements for parent container until COMMENT_ISLAND_END
114
- COMMENT_ISLAND_END /* ************* */ = 0b10000000 , // Comment island end
115
- OTHER /* ************************** */ = 0b00000000 ,
105
+ CONTAINER_MASK /* ***************** */ = 0b0000001 ,
106
+ ELEMENT /* ************************ */ = 0b0000010 , // regular element
107
+ ELEMENT_CONTAINER /* ************** */ = 0b0000011 , // container element need to descend into it
108
+ ELEMENT_SHADOW_ROOT_WRAPPER /* **** */ = 0b0000110 , // shadow root wrapper element with q:shadowroot attribute
109
+ COMMENT_SKIP_START /* ************* */ = 0b0001001 , // Comment but skip the content until COMMENT_SKIP_END
110
+ COMMENT_SKIP_END /* *************** */ = 0b0001000 , // Comment end
111
+ COMMENT_IGNORE_START /* *********** */ = 0b0010000 , // Comment ignore, descend into children and skip the content until COMMENT_ISLAND_START
112
+ COMMENT_IGNORE_END /* ************* */ = 0b0100000 , // Comment ignore end
113
+ COMMENT_ISLAND_START /* *********** */ = 0b1000001 , // Comment island, count elements for parent container until COMMENT_ISLAND_END
114
+ COMMENT_ISLAND_END /* ************* */ = 0b1000000 , // Comment island end
115
+ OTHER /* ************************** */ = 0b0000000 ,
116
116
}
117
117
118
118
/**
@@ -126,7 +126,7 @@ export function processVNodeData(document: Document) {
126
126
const qContainer = getAttribute . call ( node , Q_CONTAINER ) ;
127
127
if ( qContainer === null ) {
128
128
if ( hasAttribute . call ( node , Q_SHADOW_ROOT ) ) {
129
- return NodeType . ELEMENT_SHADOW_ROOT ;
129
+ return NodeType . ELEMENT_SHADOW_ROOT_WRAPPER ;
130
130
}
131
131
const isQElement = hasAttribute . call ( node , Q_PROPS_SEPARATOR ) ;
132
132
return isQElement ? NodeType . ELEMENT : NodeType . OTHER ;
@@ -187,12 +187,6 @@ export function processVNodeData(document: Document) {
187
187
return node ;
188
188
} ;
189
189
190
- const firstChild = ( node : Node | null ) => {
191
- // eslint-disable-next-line no-empty
192
- while ( node && ( node = node . firstChild ) && getFastNodeType ( node ) === NodeType . OTHER ) { }
193
- return node ;
194
- } ;
195
-
196
190
/**
197
191
* Process the container
198
192
*
@@ -289,21 +283,20 @@ export function processVNodeData(document: Document) {
289
283
} while ( getFastNodeType ( nextNode ) !== NodeType . COMMENT_SKIP_END ) ;
290
284
// console.log('EXIT', nextNode?.outerHTML);
291
285
walkContainer ( walker , node , node , nextNode , '' , null ! , prefix + ' ' ) ;
292
- } else if ( nodeType === NodeType . ELEMENT_SHADOW_ROOT ) {
286
+ } else if ( nodeType === NodeType . ELEMENT_SHADOW_ROOT_WRAPPER ) {
293
287
// If we are in a shadow root, we need to get the shadow root element.
294
288
nextNode = nextSibling ( node ) ;
295
289
const shadowRootContainer = node as Element | null ;
296
290
const shadowRoot = shadowRootContainer ?. shadowRoot ;
297
291
if ( shadowRoot ) {
298
- const firstShadowRootChild = firstChild ( shadowRoot ) ! ;
299
292
walkContainer (
300
293
// we need to create a new walker for the shadow root
301
294
document . createTreeWalker (
302
- firstShadowRootChild ,
295
+ shadowRoot ,
303
296
0x1 /* NodeFilter.SHOW_ELEMENT */ | 0x80 /* NodeFilter.SHOW_COMMENT */
304
297
) ,
305
298
null ,
306
- firstShadowRootChild ,
299
+ shadowRoot ,
307
300
null ,
308
301
'' ,
309
302
null ! ,
0 commit comments