mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-30 22:39:58 +02:00
Fix class collector when running with --minify
Also add a related stresstest. Fixes #7161
This commit is contained in:
@@ -87,11 +87,6 @@ func (w *cssClassCollectorWriter) Write(p []byte) (n int, err error) {
|
||||
if w.isCollecting {
|
||||
for ; i < len(p); i++ {
|
||||
b := p[i]
|
||||
if !w.inQuote && b == '/' {
|
||||
// End element, we don't care about those.
|
||||
w.endCollecting(true)
|
||||
break
|
||||
}
|
||||
w.toggleIfQuote(b)
|
||||
if !w.inQuote && b == '>' {
|
||||
w.endCollecting(false)
|
||||
|
@@ -51,6 +51,8 @@ func TestClassCollector(t *testing.T) {
|
||||
{"duplicates", `<div class="b a b"></div>`, f("div", "a b", "")},
|
||||
{"single quote", `<body class='b a'></body>`, f("body", "a b", "")},
|
||||
{"no quote", `<body class=b id=myelement></body>`, f("body", "b", "myelement")},
|
||||
// https://github.com/gohugoio/hugo/issues/7161
|
||||
{"minified a href", `<a class="b a" href=/></a>`, f("a", "a b", "")},
|
||||
|
||||
{"AlpineJS bind 1", `<body>
|
||||
<div x-bind:class="{
|
||||
|
Reference in New Issue
Block a user