From 2a915e680b14acc67b5863c97905a9382d695d0e Mon Sep 17 00:00:00 2001 From: Thomas Walpole Date: Sat, 25 Jan 2020 18:03:09 -0800 Subject: [PATCH] Minor JS cleanup --- lib/capybara/selenium/nodes/chrome_node.rb | 2 +- lib/capybara/selenium/nodes/edge_node.rb | 2 +- lib/capybara/selenium/nodes/firefox_node.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/capybara/selenium/nodes/chrome_node.rb b/lib/capybara/selenium/nodes/chrome_node.rb index b295a381..737c7fd2 100644 --- a/lib/capybara/selenium/nodes/chrome_node.rb +++ b/lib/capybara/selenium/nodes/chrome_node.rb @@ -18,7 +18,7 @@ class Capybara::Selenium::ChromeNode < Capybara::Selenium::Node # In Chrome 75+ files are appended (due to WebDriver spec - why?) so we have to clear here if its multiple and already set if browser_version >= 75.0 driver.execute_script(<<~JS, self) - if (arguments[0].multiple && (arguments[0].files.length > 0)){ + if (arguments[0].multiple && arguments[0].files.length){ arguments[0].value = null; } JS diff --git a/lib/capybara/selenium/nodes/edge_node.rb b/lib/capybara/selenium/nodes/edge_node.rb index 50cef8c0..d89ba362 100644 --- a/lib/capybara/selenium/nodes/edge_node.rb +++ b/lib/capybara/selenium/nodes/edge_node.rb @@ -18,7 +18,7 @@ class Capybara::Selenium::EdgeNode < Capybara::Selenium::Node # In Chrome 75+ files are appended (due to WebDriver spec - why?) so we have to clear here if its multiple and already set if chrome_edge? driver.execute_script(<<~JS, self) - if (arguments[0].multiple && (arguments[0].files.length > 0)){ + if (arguments[0].multiple && arguments[0].files.length){ arguments[0].value = null; } JS diff --git a/lib/capybara/selenium/nodes/firefox_node.rb b/lib/capybara/selenium/nodes/firefox_node.rb index f171e1ae..89b27382 100644 --- a/lib/capybara/selenium/nodes/firefox_node.rb +++ b/lib/capybara/selenium/nodes/firefox_node.rb @@ -26,7 +26,7 @@ class Capybara::Selenium::FirefoxNode < Capybara::Selenium::Node def set_file(value) # rubocop:disable Naming/AccessorMethodName # By default files are appended so we have to clear here if its multiple and already set driver.execute_script(<<~JS, self) - if (arguments[0].multiple && (arguments[0].files.length > 0)){ + if (arguments[0].multiple && arguments[0].files.length){ arguments[0].value = null; } JS