@@ -121,7 +121,13 @@ import { isDev } from '@qwik.dev/core/build';
121121import { qwikDebugToString } from '../debug' ;
122122import { assertDefined , assertEqual , assertFalse , assertTrue } from '../shared/error/assert' ;
123123import { QError , qError } from '../shared/error/error' ;
124- import { DEBUG_TYPE , QContainerValue , VirtualType , VirtualTypeName } from '../shared/types' ;
124+ import {
125+ DEBUG_TYPE ,
126+ QContainerValue ,
127+ VirtualType ,
128+ VirtualTypeName ,
129+ type QElement ,
130+ } from '../shared/types' ;
125131import { isText } from '../shared/utils/element' ;
126132import {
127133 dangerouslySetInnerHTML ,
@@ -210,6 +216,7 @@ export const vnode_newElement = (element: Element, elementName: string): Element
210216 assertTrue ( vnode_isElementVNode ( vnode ) , 'Incorrect format of ElementVNode.' ) ;
211217 assertFalse ( vnode_isTextVNode ( vnode ) , 'Incorrect format of ElementVNode.' ) ;
212218 assertFalse ( vnode_isVirtualVNode ( vnode ) , 'Incorrect format of ElementVNode.' ) ;
219+ ( element as QElement ) . vNode = new WeakRef ( vnode ) ;
213220 return vnode ;
214221} ;
215222
@@ -228,6 +235,7 @@ export const vnode_newUnMaterializedElement = (element: Element): ElementVNode =
228235 assertTrue ( vnode_isElementVNode ( vnode ) , 'Incorrect format of ElementVNode.' ) ;
229236 assertFalse ( vnode_isTextVNode ( vnode ) , 'Incorrect format of ElementVNode.' ) ;
230237 assertFalse ( vnode_isVirtualVNode ( vnode ) , 'Incorrect format of ElementVNode.' ) ;
238+ ( element as QElement ) . vNode = new WeakRef ( vnode ) ;
231239 return vnode ;
232240} ;
233241
@@ -670,6 +678,11 @@ export const vnode_locate = (rootVNode: ElementVNode, id: string | Element): VNo
670678 refElement = qVNodeRefs . get ( elementOffset ) ! ;
671679 } else {
672680 refElement = id ;
681+
682+ const vNode = ( refElement as QElement ) . vNode ?. deref ( ) ;
683+ if ( vNode ) {
684+ return vNode ;
685+ }
673686 }
674687 assertDefined ( refElement , 'Missing refElement.' ) ;
675688 if ( ! vnode_isVNode ( refElement ) ) {
0 commit comments