Skip to content

Script type="importmap" regression #64864

@luis-paulo-silva

Description

@luis-paulo-silva

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

The Net9 issue has already been reported and fixed here: #58973
Using Net10, razor project, and adding a <script type="importmap"> 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": {
		 }
	}
</script>

Secondary fail example

<text>
  <script type="importmap">
	 {
  		 "imports": {
  		 }
  	}
  </script>
</text>

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


It works as:

<!script type="importmap">
	 {
		 "imports": {
		 }
	}
</script>

or using the Html.Raw function

Exceptions (if any)

No response

.NET Version

10.0.101

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templates

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions