Skip to content

Commit

Permalink
Fix _has_class to avoid confusion with partial matches
Browse files Browse the repository at this point in the history
  • Loading branch information
marcandre committed Oct 11, 2016
1 parent 002a295 commit 94df4b3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/component_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 16 additions & 2 deletions spec/cases/button/with_tricky_class.inky
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
<!-- pending -->

<button href="http://example.com" class="noexpand">
A label
</button>

<button href="http://example.com" class="expand-niet">
A label
</button>

<button href="http://example.com" class="expand foo">
A label
</button>

<button href="http://example.com" class="foo expand">
A label
</button>

<button href="http://example.com" class="foo expand bar">
A label
</button>

0 comments on commit 94df4b3

Please sign in to comment.