Permalink
Browse files

Fix SelectList#{select|clear} to fire onChange events for <select> el…

…ement.
  • Loading branch information...
1 parent 979cd6d commit 26e25094724968144712bf675081f6c6bdec9764 @jarmo jarmo committed Sep 16, 2012
Showing with 10 additions and 11 deletions.
  1. +10 −11 lib/watir-classic/input_elements.rb
@@ -25,7 +25,7 @@ class SelectList < InputElement
# This method clears the selected items in the select box
def clear
perform_action do
- options.each {|option| option.clear}
+ options.each(&:clear)
end
end
@@ -94,23 +94,15 @@ class Option < Element
def select
perform_action do
- unless selected?
- ole_object.selected = true
- select_list.dispatch_event("onChange")
- @container.wait
- end
+ change_selected true unless selected?
end
end
def clear
raise TypeError, "you can only clear multi-selects" unless select_list.multiple?
perform_action do
- if selected?
- ole_object.selected = false
- select_list.dispatch_event("onChange")
- @container.wait
- end
+ change_selected false if selected?
end
end
@@ -134,6 +126,13 @@ def select_list
raise "SELECT element was not found for #{self}!" unless el
@select_list = el
end
+
+ def change_selected(value)
+ select_list.focus
+ ole_object.selected = value
+ select_list.dispatch_event("onChange")
+ @container.wait
+ end
end
#

0 comments on commit 26e2509

Please sign in to comment.