Skip to content

Commit

Permalink
Fix <button> with extra attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
marcandre committed Dec 6, 2021
1 parent c19d4fb commit b58948b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/inky/component_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ def _target_attribute(elem)

def _transform_button(component, inner)
expand = _has_class(component, 'expand')
attributes = _pass_through_attributes(component)
if component.attr('href')
target = _target_attribute(component)
extra = ' align="center" class="float-center"' if expand
inner = %{<a href="#{component.attr('href')}"#{target}#{extra}>#{inner}</a>}
inner = %{<a #{attributes}href="#{component.attr('href')}"#{target}#{extra}>#{inner}</a>}
end
inner = "<center>#{inner}</center>" if expand

Expand Down
3 changes: 3 additions & 0 deletions spec/cases/button/with_extra_attr.inky
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<button foo="bar">
A label
</button>
2 changes: 1 addition & 1 deletion spec/cases/button/with_link.inky
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<button href="http://example.com" class="some classes" foo="bar">
<button href="http://example.com" class="some classes">
A label
</button>
3 changes: 3 additions & 0 deletions spec/cases/button/with_link_and_extra_attr.inky
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<button href="http://example.com" foo="bar">
A label
</button>

0 comments on commit b58948b

Please sign in to comment.