@@ -1478,27 +1478,28 @@ const fastGetter = <T>(prototype: any, name: string): T => {
1478
1478
) ;
1479
1479
} ;
1480
1480
1481
- const isQStyleElement = ( node : Node | null ) : node is Element => {
1481
+ const hasQStyleAttribute = ( element : Element ) : boolean => {
1482
1482
return (
1483
- isElement ( node ) &&
1484
- node . nodeName === 'STYLE' &&
1485
- ( node . hasAttribute ( QScopedStyle ) || node . hasAttribute ( QStyle ) )
1483
+ element . nodeName === 'STYLE' &&
1484
+ ( element . hasAttribute ( QScopedStyle ) || element . hasAttribute ( QStyle ) )
1486
1485
) ;
1487
1486
} ;
1488
1487
1488
+ const hasPropsSeparator = ( element : Element ) : boolean => {
1489
+ return element . hasAttribute ( Q_PROPS_SEPARATOR ) ;
1490
+ } ;
1491
+
1489
1492
const materializeFromDOM = ( vParent : ElementVNode , firstChild : Node | null , vData ?: string ) => {
1490
1493
let vFirstChild : VNode | null = null ;
1491
1494
1492
- const skipStyleElements = ( ) => {
1493
- while ( isQStyleElement ( child ) ) {
1494
- // skip over style elements, as those need to be moved to the head.
1495
- // VNode pretends that `<style q:style q:sstyle>` elements do not exist.
1495
+ const skipElements = ( ) => {
1496
+ while ( isElement ( child ) && shouldSkipElement ( child ) ) {
1496
1497
child = fastNextSibling ( child ) ;
1497
1498
}
1498
1499
} ;
1499
1500
// materialize from DOM
1500
1501
let child = firstChild ;
1501
- skipStyleElements ( ) ;
1502
+ skipElements ( ) ;
1502
1503
let vChild : VNode | null = null ;
1503
1504
while ( child ) {
1504
1505
const nodeType = fastNodeType ( child ) ;
@@ -1518,7 +1519,7 @@ const materializeFromDOM = (vParent: ElementVNode, firstChild: Node | null, vDat
1518
1519
vParent . firstChild = vFirstChild = vChild ;
1519
1520
}
1520
1521
child = fastNextSibling ( child ) ;
1521
- skipStyleElements ( ) ;
1522
+ skipElements ( ) ;
1522
1523
}
1523
1524
vParent . lastChild = vChild || null ;
1524
1525
vParent . firstChild = vFirstChild ;
@@ -1785,6 +1786,17 @@ export function vnode_toString(
1785
1786
const isNumber = ( ch : number ) => /* `0` */ 48 <= ch && ch <= 57 ; /* `9` */
1786
1787
const isLowercase = ( ch : number ) => /* `a` */ 97 <= ch && ch <= 122 ; /* `z` */
1787
1788
1789
+ function shouldSkipElement ( element : Element ) {
1790
+ return (
1791
+ // Skip over elements that don't have a props separator. They are not rendered by Qwik.
1792
+ ! hasPropsSeparator ( element ) ||
1793
+ // We pretend that style element's don't exist as they can get moved out.
1794
+ // skip over style elements, as those need to be moved to the head
1795
+ // and are not included in the counts.
1796
+ hasQStyleAttribute ( element )
1797
+ ) ;
1798
+ }
1799
+
1788
1800
const stack : any [ ] = [ ] ;
1789
1801
function materializeFromVNodeData (
1790
1802
vParent : ElementVNode | VirtualVNode ,
@@ -1813,16 +1825,15 @@ function materializeFromVNodeData(
1813
1825
let combinedText : string | null = null ;
1814
1826
let container : ClientContainer | null = null ;
1815
1827
1828
+ const shouldSkipNode = ( node : Node | null ) => {
1829
+ const nodeIsElement = isElement ( node ) ;
1830
+ return ! nodeIsElement || ( nodeIsElement && shouldSkipElement ( node ) ) ;
1831
+ } ;
1832
+
1816
1833
processVNodeData ( vData , ( peek , consumeValue , consume , getChar , nextToConsumeIdx ) => {
1817
1834
if ( isNumber ( peek ( ) ) ) {
1818
1835
// Element counts get encoded as numbers.
1819
- while (
1820
- ! isElement ( child ) ||
1821
- // We pretend that style element's don't exist as they can get moved out.
1822
- // skip over style elements, as those need to be moved to the head
1823
- // and are not included in the counts.
1824
- isQStyleElement ( child )
1825
- ) {
1836
+ while ( shouldSkipNode ( child ) ) {
1826
1837
child = fastNextSibling ( child ) ;
1827
1838
if ( ! child ) {
1828
1839
throw qError ( QError . materializeVNodeDataError , [ vData , peek ( ) , nextToConsumeIdx ] ) ;
@@ -1902,8 +1913,8 @@ function materializeFromVNodeData(
1902
1913
} else if ( peek ( ) === VNodeDataChar . SLOT ) {
1903
1914
vParent . setAttr ( QSlot , consumeValue ( ) , null ) ;
1904
1915
} else {
1905
- // skip over style elements in front of text nodes, where text node is the first child (except the style node)
1906
- while ( isQStyleElement ( child ) ) {
1916
+ // skip over style or non-qwik elements in front of text nodes, where text node is the first child (except the style node)
1917
+ while ( isElement ( child ) && shouldSkipElement ( child ) ) {
1907
1918
child = fastNextSibling ( child ) ;
1908
1919
}
1909
1920
const textNode =
0 commit comments