aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/event.js
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2012-11-20 22:31:33 -0500
committerDave Methvin <dave.methvin@gmail.com>2012-11-24 14:08:51 -0500
commit1fb2f92c357b985a5ba18d0938edd27b5f64d8c3 (patch)
treeaeb57875c20c53a15c1d4ff822fdc62f1870d0b6 /test/unit/event.js
parent4fed8eb86d4b987524fd16e6c4e7be351301f38b (diff)
downloadjquery-1fb2f92c357b985a5ba18d0938edd27b5f64d8c3.tar.gz
jquery-1fb2f92c357b985a5ba18d0938edd27b5f64d8c3.zip
Fix #3827. Get the correct checkbox status for a click handler.
Diffstat (limited to 'test/unit/event.js')
-rw-r--r--test/unit/event.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/unit/event.js b/test/unit/event.js
index db968284f..f2f3cddd4 100644
--- a/test/unit/event.js
+++ b/test/unit/event.js
@@ -2831,6 +2831,35 @@ test("clone() delegated events (#11076)", function() {
clone.remove();
});
+test("checkbox state (#3827)", function() {
+ expect( 9 );
+
+ var markup = jQuery("<div><input type=checkbox><div>").appendTo("#qunit-fixture"),
+ cb = markup.find("input")[0];
+
+ jQuery(cb).on( "click", function(){
+ equal( this.checked, false, "just-clicked checkbox is not checked" );
+ });
+ markup.on( "click", function(){
+ equal( cb.checked, false, "checkbox is not checked in bubbled event" );
+ });
+
+ // Native click
+ cb.checked = true;
+ equal( cb.checked, true, "native - checkbox is initially checked" );
+ cb.click();
+ equal( cb.checked, false, "native - checkbox is no longer checked" );
+
+ // jQuery click
+ cb.checked = true;
+ equal( cb.checked, true, "jQuery - checkbox is initially checked" );
+ jQuery( cb ).click();
+ equal( cb.checked, false, "jQuery - checkbox is no longer checked" );
+
+ // Handlers only; checkbox state remains false
+ jQuery( cb ).triggerHandler( "click" );
+});
+
test("fixHooks extensions", function() {
expect( 2 );