dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.19k stars 9.93k forks source link

Ability to encapsulate a Blazor WebAssembly application into an HTML Custom Element #35372

Closed lmorvan closed 3 years ago

lmorvan commented 3 years ago

Is your feature request related to a problem? Please describe.

As part of a work on investigating micro frontends architecture, I'm trying to encapsulate a Blazor WebAssembly into an HTML Custom Element. Using HTML Custom Element allows a certain abstraction on micro frontends, compositing a final web application with micro frontends that are hiding different technologies (React, Blazor, plain old HTML, etc...). The framework for Blazor WebAssembly does seem to be only designed to describe a full website.

Describe the solution you'd like

In my investigations, I've found one hard stopper with builder.RootComponents.Add<App>("#app");. The RootComponents property does not allow finding an element from within an HTML shadowRoot, which is mandatory in HTML Custom Elements. Thus a good start of a solution would be to allow Blazor WebAssembly to access elements from within a shadow root.

SteveSandersonMS commented 3 years ago

This is something we've enabled in the 6.0 RC1 release. There's a sample at https://github.com/aspnet/AspLabs/tree/main/src/BlazorCustomElements.