Skip to content

On RenderTreeBuilder, add SetUpdatesAttributeName #11375

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 2 commits into from
Jun 20, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,7 @@ public void OpenComponent(int sequence, System.Type componentType) { }
public void OpenComponent<TComponent>(int sequence) where TComponent : Microsoft.AspNetCore.Components.IComponent { }
public void OpenElement(int sequence, string elementName) { }
public void SetKey(object value) { }
public void SetUpdatesAttributeName(string updatesAttributeName) { }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public readonly partial struct RenderTreeDiff
Expand Down
18 changes: 18 additions & 0 deletions src/Components/Components/src/RenderTree/RenderTreeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,24 @@ public void AddMultipleAttributes<T>(int sequence, IEnumerable<KeyValuePair<stri
}
}

/// <summary>
/// <para>
/// Indicates that the preceding attribute represents an event handler
/// whose execution updates the attribute with name <paramref name="updatesAttributeName"/>.
/// </para>
/// <para>
/// This information is used by the rendering system to determine whether
/// to accept a value update for the other attribute when receiving a
/// call to the event handler.
Copy link
Member

Choose a reason for hiding this comment

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

@SteveSandersonMS - are you concerned that this won't really be possible to do with manual two-way binding?

Copy link
Member Author

@SteveSandersonMS SteveSandersonMS Jun 20, 2019

Choose a reason for hiding this comment

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

Yes, and I'd be happy to discuss this whole design with you next week.

My thought was that later on, we'd also add another parameter to event handlers, e.g., @oninput:updateField="value" (or maybe call it @onevent:syncField or similar) so that it is possible to do this with a manual two-way binding. It would be optional, since it's up to you whether or not the binding enforces consistency synchronously when the event is processed.

I also thought it would be acceptable for this to be a @bind-only feature for preview 7, and maybe longer, since adding @onevent:updateField is not urgent.

/// </para>
/// </summary>
/// <param name="updatesAttributeName">The name of another attribute whose value can be updated when the event handler is executed.</param>
public void SetUpdatesAttributeName(string updatesAttributeName)
{
// TODO: This will be implemented in a later PR, once aspnetcore-tooling
// is updated to call this method.
}

/// <summary>
/// Appends a frame representing a child component.
/// </summary>
Expand Down