@@ -42,39 +42,39 @@ public bool TryFindElementById(string id, [NotNullWhen(true)] out ElementNode? e
42
42
foreach ( var kvp in Components )
43
43
{
44
44
var component = kvp . Value ;
45
- if ( TryGetElementFromChildren ( component , out element ) )
45
+ if ( TryGetElementFromChildren ( component , id , out element ) )
46
46
{
47
47
return true ;
48
48
}
49
49
}
50
50
51
51
element = null ;
52
52
return false ;
53
+ }
53
54
54
- bool TryGetElementFromChildren ( Node node , out ElementNode ? foundNode )
55
+ bool TryGetElementFromChildren ( Node node , string id , [ NotNullWhen ( true ) ] out ElementNode ? foundNode )
56
+ {
57
+ if ( node is ElementNode elementNode &&
58
+ elementNode . Attributes . TryGetValue ( "id" , out var elementId ) &&
59
+ elementId . ToString ( ) == id )
55
60
{
56
- if ( node is ElementNode elementNode &&
57
- elementNode . Attributes . TryGetValue ( "id" , out var elementId ) &&
58
- elementId ? . ToString ( ) == id )
59
- {
60
- foundNode = elementNode ;
61
- return true ;
62
- }
61
+ foundNode = elementNode ;
62
+ return true ;
63
+ }
63
64
64
- if ( node is ContainerNode containerNode )
65
+ if ( node is ContainerNode containerNode )
66
+ {
67
+ for ( var i = 0 ; i < containerNode . Children . Count ; i ++ )
65
68
{
66
- for ( var i = 0 ; i < containerNode . Children . Count ; i ++ )
69
+ if ( TryGetElementFromChildren ( containerNode . Children [ i ] , id , out foundNode ) )
67
70
{
68
- if ( TryGetElementFromChildren ( containerNode . Children [ i ] , out foundNode ) )
69
- {
70
- return true ;
71
- }
71
+ return true ;
72
72
}
73
73
}
74
-
75
- foundNode = null ;
76
- return false ;
77
74
}
75
+
76
+ foundNode = null ;
77
+ return false ;
78
78
}
79
79
80
80
private void UpdateComponent ( RenderBatch batch , int componentId , ArrayBuilderSegment < RenderTreeEdit > edits )
0 commit comments