Commit 40993056bc
Verified · cmc
internal/web/classes_test.go +7 −5
| @@ -9,10 +9,9 @@ import ( | ||
| 9 | 9 | ) |
| 10 | 10 | |
| 11 | 11 | // TestEveryTemplateClassHasARule fails on a class a template uses that |
| 12 | // no selector in style.css mentions. Template actions are removed before | |
| 13 | // matching, so a class composed at render time (chip-{{.State}}) | |
| 14 | // contributes only its literal part; the rules for the concrete values | |
| 15 | // cover the rest. | |
| 12 | // no selector in style.css mentions. Template actions are replaced by a | |
| 13 | // marker and any class token carrying one (chip-{{.State}}, l{{.Level}}) | |
| 14 | // is skipped; the rules for the concrete values cover those. | |
| 16 | 15 | func TestEveryTemplateClassHasARule(t *testing.T) { |
| 17 | 16 | css := string(StyleCSS) |
| 18 | 17 | // Every ".name" that appears in a selector position: outside braces. |
| @@ -73,9 +72,12 @@ func TestEveryTemplateClassHasARule(t *testing.T) { | ||
| 73 | 72 | if err != nil { |
| 74 | 73 | t.Fatal(err) |
| 75 | 74 | } |
| 76 | clean := actionRe.ReplaceAllString(string(src), " ") | |
| 75 | clean := actionRe.ReplaceAllString(string(src), "\x00") | |
| 77 | 76 | for _, m := range attrRe.FindAllStringSubmatch(clean, -1) { |
| 78 | 77 | for _, c := range strings.Fields(m[1]) { |
| 78 | if strings.Contains(c, "\x00") { | |
| 79 | continue // composed at render time; the concrete values have rules | |
| 80 | } | |
| 79 | 81 | if !styled[c] { |
| 80 | 82 | missing[c] = append(missing[c], e.Name()) |
| 81 | 83 | } |