aboutsummaryrefslogtreecommitdiff
path: root/src/html
diff options
context:
space:
mode:
authorAndrew Bonventre <andybons@golang.org>2019-05-05 09:35:14 -0400
committerAndrew Bonventre <andybons@golang.org>2019-05-06 17:06:16 +0000
commit5003b6264503c0858649ba5b10d4ec5c6f3902a1 (patch)
treeb0a00dea77bfc1d8a34b43c567d7d8d5dcde5c43 /src/html
parenta921881f85e3b947a541315d25bf27a3608d29e4 (diff)
downloadgo-5003b6264503c0858649ba5b10d4ec5c6f3902a1.tar.gz
go-5003b6264503c0858649ba5b10d4ec5c6f3902a1.zip
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>
Diffstat (limited to 'src/html')
-rw-r--r--src/html/template/js.go1
-rw-r--r--src/html/template/js_test.go1
2 files changed, 2 insertions, 0 deletions
diff --git a/src/html/template/js.go b/src/html/template/js.go
index 04c7c325db..7025c1cfaa 100644
--- a/src/html/template/js.go
+++ b/src/html/template/js.go
@@ -397,6 +397,7 @@ func isJSType(mimeType string) bool {
"application/ld+json",
"application/x-ecmascript",
"application/x-javascript",
+ "module",
"text/ecmascript",
"text/javascript",
"text/javascript1.0",
diff --git a/src/html/template/js_test.go b/src/html/template/js_test.go
index 05fa105be0..075adaafd3 100644
--- a/src/html/template/js_test.go
+++ b/src/html/template/js_test.go
@@ -344,6 +344,7 @@ func TestIsJsMimeType(t *testing.T) {
{"text/javascript", true},
{"application/json", true},
{"application/ld+json", true},
+ {"module", true},
}
for _, test := range tests {