1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Rename rapid set JS method and small cleanup

This commit is contained in:
Thomas Walpole 2020-05-30 13:30:02 -07:00
parent 66c573cf21
commit 5694af3c5e

View file

@ -281,7 +281,7 @@ private
driver.execute_script 'arguments[0].select()', self unless clear == :none
if rapid == true || ((value.length > auto_rapid_set_length) && rapid != false)
send_keys(value[0..3])
driver.execute_script RAPID_SET_TEXT, self, value[4...-3]
driver.execute_script RAPID_APPEND_TEXT, self, value[4...-3]
send_keys(value[-3..-1])
else
send_keys(value)
@ -534,14 +534,13 @@ private
})(arguments[0], arguments[1], arguments[2])
JS
RAPID_SET_TEXT = <<~'JS'
RAPID_APPEND_TEXT = <<~'JS'
(function(el, value) {
value = el.value + value;
if (el.maxLength && el.maxLength != -1){
value = el.value + value;
el.value = value.slice(0, el.maxLength);
} else {
el.value = el.value + value;
value = value.slice(0, el.maxLength);
}
el.value = value;
})(arguments[0], arguments[1])
JS