@@ -19,6 +19,7 @@ internal sealed class RenderedComponent<TComponent> : ComponentState, IRenderedC
1919
2020 private string markup = string . Empty ;
2121 private INodeList ? latestRenderNodes ;
22+ private int ? rootComponentId ;
2223
2324 /// <summary>
2425 /// Gets the component under test.
@@ -68,6 +69,12 @@ public INodeList Nodes
6869 get
6970 {
7071 EnsureComponentNotDisposed ( ) ;
72+
73+ if ( rootComponentId . HasValue )
74+ {
75+ return latestRenderNodes ??= ResolveNodesFromRootDom ( ) ;
76+ }
77+
7178 return latestRenderNodes ??= htmlParser . Parse ( Markup ) ;
7279 }
7380 }
@@ -133,6 +140,7 @@ public void UpdateState(bool hasRendered, bool isMarkupGenerationRequired)
133140 private void UpdateMarkup ( )
134141 {
135142 latestRenderNodes = null ;
143+ renderer . InvalidateBoundaryNodesCache ( ComponentId ) ;
136144 var newMarkup = Htmlizer . GetHtml ( ComponentId , renderer ) ;
137145
138146 // Volatile write is necessary to ensure the updated markup
@@ -142,6 +150,20 @@ private void UpdateMarkup()
142150 Volatile . Write ( ref markup , newMarkup ) ;
143151 }
144152
153+ public int ? RootComponentId => rootComponentId ;
154+
155+ public void SetRootComponentId ( int rootComponentId )
156+ {
157+ this . rootComponentId = rootComponentId ;
158+ latestRenderNodes = null ;
159+ }
160+
161+ private INodeList ResolveNodesFromRootDom ( )
162+ {
163+ var fullDom = renderer . GetBoundaryNodesForComponent ( rootComponentId ! . Value ) ;
164+ return ComponentBoundaryNodeExtractor . Extract ( fullDom , ComponentId ) ;
165+ }
166+
145167 /// <summary>
146168 /// Ensures that the underlying component behind the
147169 /// fragment has not been removed from the render tree.
0 commit comments