dotnet / dotnet/aspnetcore

`shadowrootmode` attribute does not work in Blazor files

Open
#55,164 0 comments 0 reactions 0 assignees View on GitHub
area-blazor enhancement
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

Adding `` to a Blazor file produces a regular `template` element with a DocumentFragment child node.

### Expected Behavior

The `` should be parsed as a declarative shadow DOM as it would be in a regular HTML file.

### Steps To Reproduce

1. Create a new Blazor project in .NET 8
2. Add `Test` to a .razor page.
3. Run the app in a browser.

### Exceptions (if any)

_No response_

### .NET Version

8.0.202

### Anything else?

(This rule)[https://developer.chrome.com/docs/css-ui/declarative-shadow-dom#parser-only] seems to be the cause of the bug. When Blazor builds the component, it should account for `shadowrootmode` attributes and create a shadow DOM if necessary.

**NOTE:** This was originally reported at #44986, however this was before the `shadowrootmode` attribute was standardized and widely supported. I am reopening this as a bug report now that this has changed.

Also note that #44986 was marked as a duplicate of #34641 which is requests a very different feature from this bug report.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.