[Blazor] Explicitly set values should trump splatted attributes
See original GitHub issueThe position of @attributes relative to the position of element attributes is important. When @attributes are splatted on the element, the attributes are processed from right to left (last to first)
https://docs.microsoft.com/en-us/aspnet/core/blazor/components/?view=aspnetcore-3.1
Attributes having to have a special order is not immediately obvious when trying to understand why an explicitly set parameter value is incorrect.
The position of @attributes
should be irrelevant. The @attributes
should be splatted first so that explicitly set parameters cannot be overridden by the consumer of the component.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (3 by maintainers)
Top Results From Across the Web
ASP.NET Core Blazor attribute splatting and arbitrary ...
Learn how components can capture and render additional attributes in addition to the component's declared parameters.
Read more >Blazor Attribute Splatting
In this article we will discuss, what is Attribute Splatting in Blazor with ... It is tedious to declare these parameters in code...
Read more >Capturing unmatched attributes and attribute splatting in ...
In this post, I describe how to use attribute splatting in ASP. ... @attributes will be expanded with all unmatched parameters *@ <input ......
Read more >Blazor Attribute Splatting Fails with Int Values · Issue #22048
If I specify MaxLength on RadzenTextBox within the component, it works. If I specify MaxLength when declaring the component, however, it fails.
Read more >Is there anyway to get attribute splatting to work with ...
There is a hacky work around I found but it leaves much to be desired. Does anyone know how I could possible get...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ah no, not that it matters now, but you were thinking of a different approach.
All you have to do is this
The way SetParametersAsync is implemented today, if you override you’ll have to call base for things like OnInitialized to run when extending componentbase (the most common case). If you override, do something and call base afterwards, it will have no effect since the base implementation will set the parameters. If you call base and then do something afterward, all the OnInititalized and OnParametersSet will run with the wrong set of parameter values. That is something we could fix by introducing an additional lifecycle method that can be overriden, but we haven’t seen the need for it yet.