diff --git a/property.go b/property.go index beabc5d..ac8e471 100644 --- a/property.go +++ b/property.go @@ -137,12 +137,16 @@ func (s *Selection) AddClass(class ...string) *Selection { // HasClass determines whether any of the matched elements are assigned the // given class. func (s *Selection) HasClass(class string) bool { + rawClass := class class = " " + class + " " for _, n := range s.Nodes { if n.Type != html.ElementNode { continue } if attr := getAttributePtr("class", n); attr != nil { + if !strings.Contains(attr.Val, rawClass) { + continue + } val := classTrimReplacer.Replace(attr.Val) if strings.Contains(" "+val+" ", class) { return true