Introduce package for rendering Blazor components with custom HTML elements
MackinnonBuck opened this issue · comments
Background and Motivation
We currently have an experimental support package Microsoft.AspNetCore.Components.CustomElements that enables rendering Blazor components using custom HTML elements. This makes it easier to utilize Blazor in projects built on other web frameworks. Since this is a scenario we strongly care about, we'd like to productize this feature as an officially supported package (see #38447).
Proposed API
namespace Microsoft.AspNetCore.Components.Web;
+ public static class CustomElementsJSComponentConfigurationExtensions
{
+ public void RegisterAsCustomElement<TComponent>(this IJSComponentConfiguration configuration, string customElementName) where TComponent : IComponent;
}
Usage Example
var builder = WebAssemblyHostBuilder.CreateDefault(args);
// ...
builder.RootComponents.RegisterAsCustomElement<MyComponent>("my-custom-element");
Thank you for submitting this for API review. This will be reviewed by @dotnet/aspnet-api-review at the next meeting of the ASP.NET Core API Review group. Please ensure you take a look at the API review process documentation and ensure that:
- The PR contains changes to the reference-assembly that describe the API change. Or, you have included a snippet of reference-assembly-style code that illustrates the API change.
- The PR describes the impact to users, both positive (useful new APIs) and negative (breaking changes).
- Someone is assigned to "champion" this change in the meeting, and they understand the impact and design of the change.
I think the return type is currently void
instead of Task
.
Diff from internal discussion:
namespace Microsoft.AspNetCore.Components.Web;
public static class CustomElementsJSComponentConfigurationExtensions
{
- public void RegisterAsCustomElement<TComponent>(this IJSComponentConfiguration configuration, string customElementName) where TComponent : IComponent;
+ public void RegisterCustomElement<TComponent>(this IJSComponentConfiguration configuration, string identifier) where TComponent : IComponent;
}
New package: Microsoft.AspNetCore.Componenets.CustomElements
+ namespace Microsoft.AspNetCore.Components.Web;
+ public static class CustomElementsJSComponentConfigurationExtensions
+ {
+ public static void RegisterCustomElement<TComponent>(this IJSComponentConfiguration configuration, string identifier) where TComponent : IComponent
+ }
API approved