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