Commit 5003b626 authored by Andrew Bonventre's avatar Andrew Bonventre

html/template: add support for JavaScript modules

html/template does not properly treat JavaScript code as
JavaScript when using a <script> tag with "module" set as
the type attribute.

See also:
https://www.w3.org/TR/html5/semantics-scripting.html#element-attrdef-script-type and
https://html.spec.whatwg.org/multipage/scripting.html#the-script-element:module-script-2

Original change from tomut at https://golang.org/cl/135417

Fixes #31327

Change-Id: I6239be69cd7994990d091400664e4474124a98fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/175218Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent a921881f
...@@ -397,6 +397,7 @@ func isJSType(mimeType string) bool { ...@@ -397,6 +397,7 @@ func isJSType(mimeType string) bool {
"application/ld+json", "application/ld+json",
"application/x-ecmascript", "application/x-ecmascript",
"application/x-javascript", "application/x-javascript",
"module",
"text/ecmascript", "text/ecmascript",
"text/javascript", "text/javascript",
"text/javascript1.0", "text/javascript1.0",
......
...@@ -344,6 +344,7 @@ func TestIsJsMimeType(t *testing.T) { ...@@ -344,6 +344,7 @@ func TestIsJsMimeType(t *testing.T) {
{"text/javascript", true}, {"text/javascript", true},
{"application/json", true}, {"application/json", true},
{"application/ld+json", true}, {"application/ld+json", true},
{"module", true},
} }
for _, test := range tests { for _, test := range tests {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment