Skip to content

Commit 943348f

Browse files
committed
HTML: don't skip text with templates in select tag, fixes #698
1 parent 10917c4 commit 943348f

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

html/html.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st
515515

516516
// skip text in select and optgroup tags
517517
if t.Hash == Select || t.Hash == Optgroup {
518-
if next := tb.Peek(0); next.TokenType == html.TextToken {
518+
if next := tb.Peek(0); next.TokenType == html.TextToken && !next.HasTemplate {
519519
tb.Shift()
520520
}
521521
}

html/html_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ func TestHTMLTemplates(t *testing.T) {
373373
{`<div style=" color: {{.Color}} ">`, `<div style=" color: {{.Color}} ">`},
374374
{`<script>alert( {{.Alert}} )</script>`, `<script>alert( {{.Alert}} )</script>`},
375375
{`<button onclick=" alert( {{.Alert}} ) ">`, `<button onclick=" alert( {{.Alert}} ) ">`},
376+
{`<select>{{ range . }}<option>{{ . }}{{ end }}</select>`, `<select>{{ range . }}<option>{{ . }}{{ end }}</select>`},
376377
}
377378

378379
m := minify.New()

0 commit comments

Comments
 (0)