Skip to content

Build fixups in master #19338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions src/Components/Ignitor/src/ElementHive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,39 +42,39 @@ public bool TryFindElementById(string id, [NotNullWhen(true)] out ElementNode? e
foreach (var kvp in Components)
{
var component = kvp.Value;
if (TryGetElementFromChildren(component, out element))
if (TryGetElementFromChildren(component, id, out element))
{
return true;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This complains because element isn't guaranteed to be non-null. Only appears when building in VS

}
}

element = null;
return false;
}

bool TryGetElementFromChildren(Node node, out ElementNode? foundNode)
bool TryGetElementFromChildren(Node node, string id, [NotNullWhen(true)] out ElementNode? foundNode)
{
if (node is ElementNode elementNode &&
elementNode.Attributes.TryGetValue("id", out var elementId) &&
elementId.ToString() == id)
{
if (node is ElementNode elementNode &&
elementNode.Attributes.TryGetValue("id", out var elementId) &&
elementId?.ToString() == id)
{
foundNode = elementNode;
return true;
}
foundNode = elementNode;
return true;
}

if (node is ContainerNode containerNode)
if (node is ContainerNode containerNode)
{
for (var i = 0; i < containerNode.Children.Count; i++)
{
for (var i = 0; i < containerNode.Children.Count; i++)
if (TryGetElementFromChildren(containerNode.Children[i], id, out foundNode))
{
if (TryGetElementFromChildren(containerNode.Children[i], out foundNode))
{
return true;
}
return true;
}
}

foundNode = null;
return false;
}

foundNode = null;
return false;
}

private void UpdateComponent(RenderBatch batch, int componentId, ArrayBuilderSegment<RenderTreeEdit> edits)
Expand Down
Loading