diff --git a/css.go b/css.go index 7aaa432..6fb4cbc 100644 --- a/css.go +++ b/css.go @@ -378,8 +378,12 @@ func (s *subclassSelectorMatcher) match(n *html.Node) bool { if s.classSelector != "" { for _, a := range n.Attr { - if a.Key == "class" && a.Val == s.classSelector { - return true + if a.Key == "class" { + for _, val := range strings.Fields(a.Val) { + if val == s.classSelector { + return true + } + } } } return false diff --git a/css_test.go b/css_test.go index 17e4f6d..7fa11a4 100644 --- a/css_test.go +++ b/css_test.go @@ -139,6 +139,14 @@ func TestSelector(t *testing.T) { `
`, }, }, + { + ".foo", + `