From 94df4b3135b03a392c1925f92e7e88c3c2fbe9de Mon Sep 17 00:00:00 2001 From: Marc-Andre Lafortune Date: Mon, 10 Oct 2016 22:40:00 -0400 Subject: [PATCH] Fix _has_class to avoid confusion with partial matches --- lib/component_factory.rb | 2 +- spec/cases/button/with_tricky_class.inky | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) 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 @@ - - + + + + + + + +