dotnet / dotnet/aspnetcore

Script type="importmap" regression

Open
#64,864 3 comments 4 reactions 0 assignees View on GitHub
area-mvc
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Describe the bug

The Net9 issue has already been reported and fixed here: https://github.com/dotnet/aspnetcore/issues/58973
Using Net10, razor project, and adding a tag and attribute causes the type attribute to be stripped from the script element.

It only works if Html.Raw is used to bypass the validations, or if the notation "<!script...>" is used. Notice the exclamation mark.

### Expected Behavior

The script tag should retain the type attribute when "importmap" is input.

### Steps To Reproduce

## Steps

1 - New Net10 razor project.
2 - Insert one of these scripts (or both - alternatively) on the index page.

### Primary fail example
```
<script type="importmap">
{
"imports": {
}
}

```

### Secondary fail example
```


{
"imports": {
}
}

```

3 - Start the project.
4 - Open the dev tools.
5 - Refresh.
6 - See it break with `Uncaught SyntaxError: unexpected token: ':' `

----

It works as:
```

{
"imports": {
}
}

```

or using the Html.Raw function

### Exceptions (if any)

_No response_

### .NET Version

10.0.101

### Anything else?

_No response_

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.