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
987c44be
Commit
987c44be
authored
Jan 17, 2011
by
jeresig
Browse files
Options
Browse Files
Download
Plain Diff
Merging pull request 183 for #7793.
parents
ac2e731b
007e2d15
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
5 deletions
+13
-5
event.js
src/event.js
+1
-1
event.js
test/unit/event.js
+12
-4
No files found.
src/event.js
View file @
987c44be
...
...
@@ -603,7 +603,7 @@ jQuery.Event = function( src ) {
// Events bubbling up the document may have been marked as prevented
// by a handler lower down the tree; reflect the correct value.
this
.
isDefaultPrevented
=
(
src
.
defaultPrevented
||
src
.
returnValue
===
false
||
this
.
isDefaultPrevented
=
(
src
.
defaultPrevented
||
src
.
returnValue
===
false
||
src
.
getPreventDefault
&&
src
.
getPreventDefault
())
?
returnTrue
:
returnFalse
;
// Event type
...
...
test/unit/event.js
View file @
987c44be
...
...
@@ -295,15 +295,15 @@ test("live/delegate immediate propagation", function() {
$p
.
undelegate
(
"click"
);
});
test
(
"bind/delegate bubbling, isDefaultPrevented
(Bug #7793)
"
,
function
()
{
test
(
"bind/delegate bubbling, isDefaultPrevented"
,
function
()
{
expect
(
2
);
var
$anchor2
=
jQuery
(
"#anchor2"
),
$main
=
jQuery
(
"#main"
),
fakeClick
=
function
(
$jq
)
{
// Use a native click so we don't get jQuery simulated bubbling
if
(
document
.
createEvent
)
{
var
e
=
document
.
createEvent
(
"MouseEvents"
);
e
.
initEvent
(
"click"
,
true
,
true
);
var
e
=
document
.
createEvent
(
'MouseEvents'
);
e
.
initEvent
(
"click"
,
true
,
true
);
$jq
[
0
].
dispatchEvent
(
e
);
}
else
if
(
$jq
[
0
].
click
)
{
...
...
@@ -314,7 +314,15 @@ test("bind/delegate bubbling, isDefaultPrevented (Bug #7793)", function() {
e
.
preventDefault
();
});
$main
.
delegate
(
"#foo"
,
"click"
,
function
(
e
)
{
equals
(
e
.
isDefaultPrevented
(),
true
,
"isDefaultPrevented true passed to bubbled event"
);
var
orig
=
e
.
originalEvent
;
if
(
typeof
(
orig
.
defaultPrevented
)
===
"boolean"
||
typeof
(
orig
.
returnValue
)
===
"boolean"
||
orig
.
getPreventDefault
)
{
equals
(
e
.
isDefaultPrevented
(),
true
,
"isDefaultPrevented true passed to bubbled event"
);
}
else
{
// Opera < 11 doesn't implement any interface we can use, so give it a pass
ok
(
true
,
"isDefaultPrevented not supported by this browser, test skipped"
);
}
});
fakeClick
(
$anchor2
);
$anchor2
.
unbind
(
"click"
);
...
...
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