Skip to content

Commit 5003b62

Browse files
committed
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/+/175218 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
1 parent a921881 commit 5003b62

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

src/html/template/js.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ func isJSType(mimeType string) bool {
397397
"application/ld+json",
398398
"application/x-ecmascript",
399399
"application/x-javascript",
400+
"module",
400401
"text/ecmascript",
401402
"text/javascript",
402403
"text/javascript1.0",

src/html/template/js_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ func TestIsJsMimeType(t *testing.T) {
344344
{"text/javascript", true},
345345
{"application/json", true},
346346
{"application/ld+json", true},
347+
{"module", true},
347348
}
348349

349350
for _, test := range tests {

0 commit comments

Comments
 (0)