diff --git a/lib/component_factory.rb b/lib/component_factory.rb
index 60567a8..17da3ae 100644
--- a/lib/component_factory.rb
+++ b/lib/component_factory.rb
@@ -18,7 +18,7 @@ def _pass_through_attributes(elem)
end
def _has_class(elem, klass)
- (elem.attr('class') || '').include?(klass)
+ elem.attr('class') =~ /(^|\s)#{klass}($|\s)/
end
def _combine_classes(elem, extra_classes)
diff --git a/spec/cases/button/with_tricky_class.inky b/spec/cases/button/with_tricky_class.inky
index b8adefc..3f4d2da 100644
--- a/spec/cases/button/with_tricky_class.inky
+++ b/spec/cases/button/with_tricky_class.inky
@@ -1,5 +1,19 @@
-
-
+
+
+
+
+
+
+
+