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
0252b782
Commit
0252b782
authored
Jan 28, 2010
by
jeresig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Provide a way to simulate default browser actions. Fixes #5973.
parent
31f1e995
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
3 deletions
+11
-3
event.js
src/event.js
+5
-2
event.js
test/unit/event.js
+6
-1
No files found.
src/event.js
View file @
0252b782
...
@@ -333,9 +333,12 @@ jQuery.event = {
...
@@ -333,9 +333,12 @@ jQuery.event = {
} else if ( !event.isDefaultPrevented() ) {
} else if ( !event.isDefaultPrevented() ) {
var target = event.target, old,
var target = event.target, old,
isClick = jQuery.nodeName(target, "
a
") && type === "
click
";
isClick = jQuery.nodeName(target, "
a
") && type === "
click
",
special = jQuery.event.special[ type ] || {};
if ( (!special._default || special._default.call( elem, event ) === false) &&
!isClick && !(target && target.nodeName && jQuery.noData[target.nodeName.toLowerCase()]) ) {
if ( !isClick && !(target && target.nodeName && jQuery.noData[target.nodeName.toLowerCase()]) ) {
try {
try {
if ( target[ type ] ) {
if ( target[ type ] ) {
// Make sure that we don't accidentally re-trigger the onFOO events
// Make sure that we don't accidentally re-trigger the onFOO events
...
...
test/unit/event.js
View file @
0252b782
...
@@ -72,7 +72,7 @@ test("bind(), multiple events at once and namespaces", function() {
...
@@ -72,7 +72,7 @@ test("bind(), multiple events at once and namespaces", function() {
});
});
test
(
"bind(), namespace with special add"
,
function
()
{
test
(
"bind(), namespace with special add"
,
function
()
{
expect
(
9
);
expect
(
18
);
var
div
=
jQuery
(
"<div/>"
).
bind
(
"test"
,
function
(
e
)
{
var
div
=
jQuery
(
"<div/>"
).
bind
(
"test"
,
function
(
e
)
{
ok
(
true
,
"Test event fired."
);
ok
(
true
,
"Test event fired."
);
...
@@ -81,6 +81,11 @@ test("bind(), namespace with special add", function() {
...
@@ -81,6 +81,11 @@ test("bind(), namespace with special add", function() {
var
i
=
0
;
var
i
=
0
;
jQuery
.
event
.
special
.
test
=
{
jQuery
.
event
.
special
.
test
=
{
_default
:
function
(
e
)
{
equals
(
this
,
document
,
"Make sure we're at the top of the chain."
);
equals
(
e
.
type
,
"test"
,
"And that we're still dealing with a test event."
);
equals
(
e
.
target
,
div
[
0
],
"And that the target is correct."
);
},
setup
:
function
(){},
setup
:
function
(){},
teardown
:
function
(){},
teardown
:
function
(){},
add
:
function
(
handler
,
data
,
namespaces
)
{
add
:
function
(
handler
,
data
,
namespaces
)
{
...
...
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