Skip to content

Commit

Permalink
Fix details/summary clicking in racktest driver
Browse files Browse the repository at this point in the history
  • Loading branch information
twalpole committed Jan 26, 2020
1 parent 5bea67c commit 0783f95
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/capybara/rack_test/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ def click(keys = [], **options)
set(!checked?)
elsif tag_name == 'label'
click_label
elsif tag_name == 'details'
toggle_details
elsif (details = native.xpath('.//ancestor-or-self::details').last)
toggle_details(details)
end
end

Expand Down Expand Up @@ -256,11 +256,14 @@ def click_label
labelled_control.set(!labelled_control.checked?) if checkbox_or_radio?(labelled_control)
end

def toggle_details
if native.has_attribute?('open')
native.remove_attribute('open')
def toggle_details(details = nil)
details ||= native.xpath('.//ancestor-or-self::details').last
return unless details

if details.has_attribute?('open')
details.remove_attribute('open')
else
native.set_attribute('open', 'open')
details.set_attribute('open', 'open')
end
end

Expand Down

0 comments on commit 0783f95

Please sign in to comment.