Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Trigger change event on checkbox and radio button when checked state …

…is changed
  • Loading branch information...
commit 465e5edb1298df9bd237d95b680b27c4451f82d9 1 parent d7f491d
Vasily Reys authored jferris committed
Showing with 3 additions and 2 deletions.
  1. +2 −2 spec/driver_spec.rb
  2. +1 −0  src/capybara.js
View
4 spec/driver_spec.rb
@@ -467,12 +467,12 @@
it "triggers radio input events" do
subject.find("//input[@type='radio']").first.set(true)
- subject.find("//li").map(&:text).should == %w(click)
+ subject.find("//li").map(&:text).should == %w(click change)
end
it "triggers checkbox events" do
subject.find("//input[@type='checkbox']").first.set(true)
- subject.find("//li").map(&:text).should == %w(click)
+ subject.find("//li").map(&:text).should == %w(click change)
end
end
View
1  src/capybara.js
@@ -105,6 +105,7 @@ Capybara = {
} else if(type == "checkbox" || type == "radio") {
node.checked = (value == "true");
this.trigger(index, "click");
+ this.trigger(index, "change");
} else {
node.value = value;
}

4 comments on commit 465e5ed

@fxposter

Well, It's cool, but http://www.quirksmode.org/dom/events/change.html shows that IE's handling of change event on checkboxes is far from perfect...

@jferris
Owner

Are you saying that capybara-webkit's new behavior is incorrect?

@fxposter

It depends :) From the point of view of Firefox, for example, it is truly valid behavior. From IE's point of view - it is not. Personally I think it's the right thing :)

@jferris
Owner

Yeah, I think it makes sense to behave like Safari/Chrome as much as possible. We can't simulate other DOMs, etc, since we only have one implementation.

Please sign in to comment.
Something went wrong with that request. Please try again.