Skip to content
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

Introduce package for rendering Blazor components with custom HTML elements #42329

Closed
MackinnonBuck opened this issue Jun 21, 2022 · 4 comments · Fixed by #42314
Closed

Introduce package for rendering Blazor components with custom HTML elements #42329

MackinnonBuck opened this issue Jun 21, 2022 · 4 comments · Fixed by #42314
Assignees
Labels
api-approved API was approved in API review, it can be implemented area-blazor Includes: Blazor, Razor Components
Milestone

Comments

@MackinnonBuck
Copy link
Member

MackinnonBuck commented Jun 21, 2022

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");
@MackinnonBuck MackinnonBuck added api-suggestion Early API idea and discussion, it is NOT ready for implementation area-blazor Includes: Blazor, Razor Components api-ready-for-review API is ready for formal API review - https://github.com/dotnet/apireviews labels Jun 21, 2022
@MackinnonBuck MackinnonBuck self-assigned this Jun 21, 2022
@ghost
Copy link

ghost commented Jun 21, 2022

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.

@campersau
Copy link
Contributor

I think the return type is currently void instead of Task.

@mkArtakMSFT mkArtakMSFT added this to the 7.0-preview7 milestone Jun 22, 2022
@MackinnonBuck
Copy link
Member Author

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;
}

@BrennanConroy
Copy link
Member

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

@BrennanConroy BrennanConroy added api-approved API was approved in API review, it can be implemented and removed api-suggestion Early API idea and discussion, it is NOT ready for implementation api-ready-for-review API is ready for formal API review - https://github.com/dotnet/apireviews labels Jun 23, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Jul 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-approved API was approved in API review, it can be implemented area-blazor Includes: Blazor, Razor Components
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants