Permalink
Browse files

Simulate browsers events more closely

  • Loading branch information...
1 parent 16c1637 commit 51c4dfe1414a9b1620dfb61db456646f51a782dd @halogenandtoast halogenandtoast committed Jan 27, 2012
Showing with 6 additions and 10 deletions.
  1. +2 −2 spec/driver_spec.rb
  2. +4 −8 src/capybara.js
View
@@ -637,12 +637,12 @@
it "triggers radio input events" do
subject.find("//input[@type='radio']").first.set(true)
- subject.find("//li").map(&:text).should == %w(mousedown mouseup click change)
+ subject.find("//li").map(&:text).should == %w(mousedown mouseup change click)
end
it "triggers checkbox events" do
subject.find("//input[@type='checkbox']").first.set(true)
- subject.find("//li").map(&:text).should == %w(mousedown mouseup click change)
+ subject.find("//li").map(&:text).should == %w(mousedown mouseup change click)
end
end
View
@@ -181,17 +181,13 @@ Capybara = {
this.trigger(index, "blur");
} else if (type === "checkbox" || type === "radio") {
- node.checked = (value === "true");
- this.trigger(index, "mousedown");
- this.trigger(index, "mouseup");
- this.trigger(index, "click");
- this.trigger(index, "change");
+ if (node.checked != (value === "true")) {
+ this.click(index)
+ }
} else if (type === "file") {
this.lastAttachedFile = value;
- this.trigger(index, "mousedown");
- this.trigger(index, "mouseup");
- this.trigger(index, "click");
+ this.click(index)
} else {
node.value = value;

0 comments on commit 51c4dfe

Please sign in to comment.