Skip to content

Commit f72d9cc

Browse files
committed
Revert "Implement date input types based on the capybara selenium driver"
This reverts commit 814bc28.
1 parent 814bc28 commit f72d9cc

File tree

1 file changed

+2
-39
lines changed

1 file changed

+2
-39
lines changed

lib/capybara/cuprite/node.rb

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -101,28 +101,8 @@ def set(value, options = {})
101101
when "file"
102102
files = value.respond_to?(:to_ary) ? value.to_ary.map(&:to_s) : value.to_s
103103
command(:select_file, files)
104-
when 'date'
105-
if value.respond_to?(:to_time)
106-
set_value_js(value.to_date.iso8601)
107-
else
108-
command(:set, value.to_s)
109-
end
110-
when 'time'
111-
if value.respond_to?(:to_time) && !value.is_a?(String)
112-
set_value_js(value.to_time.strftime('%H:%M'))
113-
else
114-
command(:set, value.to_s)
115-
end
116-
when 'datetime-local'
117-
if value.respond_to?(:to_time) && !value.is_a?(String)
118-
set_value_js(value.to_time.strftime('%Y-%m-%dT%H:%M'))
119-
else
120-
command(:set, value.to_s)
121-
end
122-
when 'range'
123-
set_value_js(value)
124-
when 'color'
125-
set_value_js(value)
104+
when "color"
105+
node.evaluate("this.setAttribute('value', '#{value}')")
126106
else
127107
command(:set, value.to_s)
128108
end
@@ -134,23 +114,6 @@ def set(value, options = {})
134114
end
135115
end
136116

137-
# Copied from MIT licensed capybara project
138-
# revision 0be79d6
139-
# path lib/capybara/selenium/node.rb
140-
def set_value_js(value)
141-
driver.execute_script(<<-JS, self, value)
142-
if (arguments[0].readOnly) { return };
143-
if (document.activeElement !== arguments[0]){
144-
arguments[0].focus();
145-
}
146-
if (arguments[0].value != arguments[1]) {
147-
arguments[0].value = arguments[1]
148-
arguments[0].dispatchEvent(new InputEvent('input'));
149-
arguments[0].dispatchEvent(new Event('change', { bubbles: true }));
150-
}
151-
JS
152-
end
153-
154117
def select_option
155118
command(:select, true)
156119
end

0 commit comments

Comments
 (0)