Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
1fb2f92c
Commit
1fb2f92c
authored
Nov 21, 2012
by
Dave Methvin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #3827. Get the correct checkbox status for a click handler.
parent
4fed8eb8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
3 deletions
+40
-3
event.js
src/event.js
+10
-2
event.js
test/unit/event.js
+29
-0
manipulation.js
test/unit/manipulation.js
+1
-1
No files found.
src/event.js
View file @
1fb2f92c
...
@@ -263,7 +263,7 @@ jQuery.event = {
...
@@ -263,7 +263,7 @@ jQuery.event = {
// Allow special events to draw outside the lines
// Allow special events to draw outside the lines
special
=
jQuery
.
event
.
special
[
type
]
||
{};
special
=
jQuery
.
event
.
special
[
type
]
||
{};
if
(
special
.
trigger
&&
special
.
trigger
.
apply
(
elem
,
data
)
===
false
)
{
if
(
!
onlyHandlers
&&
special
.
trigger
&&
special
.
trigger
.
apply
(
elem
,
data
)
===
false
)
{
return
;
return
;
}
}
...
@@ -523,7 +523,15 @@ jQuery.event = {
...
@@ -523,7 +523,15 @@ jQuery.event = {
// Prevent triggered image.load events from bubbling to window.load
// Prevent triggered image.load events from bubbling to window.load
noBubble
:
true
noBubble
:
true
},
},
click
:
{
// For checkbox, fire native event so checked state will be right
trigger
:
function
()
{
if
(
jQuery
.
nodeName
(
this
,
"input"
)
&&
this
.
type
===
"checkbox"
&&
this
.
click
)
{
this
.
click
();
return
false
;
}
}
},
focus
:
{
focus
:
{
delegateType
:
"focusin"
delegateType
:
"focusin"
},
},
...
...
test/unit/event.js
View file @
1fb2f92c
...
@@ -2831,6 +2831,35 @@ test("clone() delegated events (#11076)", function() {
...
@@ -2831,6 +2831,35 @@ test("clone() delegated events (#11076)", function() {
clone
.
remove
();
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
()
{
test
(
"fixHooks extensions"
,
function
()
{
expect
(
2
);
expect
(
2
);
...
...
test/unit/manipulation.js
View file @
1fb2f92c
...
@@ -100,7 +100,7 @@ var testWrap = function(val) {
...
@@ -100,7 +100,7 @@ var testWrap = function(val) {
ok
(
checkbox
.
checked
,
"Checkbox's state is erased after wrap() action, see #769"
);
ok
(
checkbox
.
checked
,
"Checkbox's state is erased after wrap() action, see #769"
);
jQuery
(
checkbox
).
wrap
(
val
(
"<div id='c1' style='display:none;'></div>"
));
jQuery
(
checkbox
).
wrap
(
val
(
"<div id='c1' style='display:none;'></div>"
));
ok
(
checkbox
.
checked
,
"Checkbox's state is erased after wrap() action, see #769"
);
ok
(
checkbox
.
checked
,
"Checkbox's state is erased after wrap() action, see #769"
);
}).
click
();
}).
prop
(
"checked"
,
false
)[
0
].
click
();
// using contents will get comments regular, text, and comment nodes
// using contents will get comments regular, text, and comment nodes
var
j
=
jQuery
(
"#nonnodes"
).
contents
();
var
j
=
jQuery
(
"#nonnodes"
).
contents
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment