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
5d033dba
Commit
5d033dba
authored
Apr 21, 2008
by
Brandon Aaron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Trigger onclick handlers of links
parent
a9fe9a2a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
3 deletions
+10
-3
event.js
src/event.js
+2
-2
event.js
test/unit/event.js
+8
-1
No files found.
src/event.js
View file @
5d033dba
...
...
@@ -203,8 +203,8 @@ jQuery.event = {
if
(
jQuery
.
isFunction
(
jQuery
.
data
(
elem
,
"handle"
)
)
)
val
=
jQuery
.
data
(
elem
,
"handle"
).
apply
(
elem
,
data
);
// Handle triggering native .onfoo handlers
if
(
!
fn
&&
elem
[
"on"
+
type
]
&&
elem
[
"on"
+
type
].
apply
(
elem
,
data
)
===
false
)
// Handle triggering native .onfoo handlers
(and on links since we don't call .click() for links)
if
(
(
!
fn
||
(
jQuery
.
nodeName
(
elem
,
'a'
)
&&
type
==
"click"
))
&&
elem
[
"on"
+
type
]
&&
elem
[
"on"
+
type
].
apply
(
elem
,
data
)
===
false
)
val
=
false
;
// Extra functions don't get the custom event object
...
...
test/unit/event.js
View file @
5d033dba
...
...
@@ -113,7 +113,7 @@ test("bind(), namespaced events, cloned events", function() {
});
test
(
"click()"
,
function
()
{
expect
(
4
);
expect
(
5
);
$
(
'<li><a href="#">Change location</a></li>'
).
prependTo
(
'#firstUL'
).
find
(
'a'
).
bind
(
'click'
,
function
()
{
var
close
=
$
(
'spanx'
,
this
);
// same with $(this).find('span');
ok
(
close
.
length
==
0
,
"Context element does not exist, length must be zero"
);
...
...
@@ -131,6 +131,13 @@ test("click()", function() {
};
$
(
'#firstp'
).
click
();
ok
(
counter
==
1
,
"Check that click, triggers onclick event handler also"
);
var
clickCounter
=
0
;
$
(
'#simon1'
)[
0
].
onclick
=
function
(
event
)
{
clickCounter
++
;
};
$
(
'#simon1'
).
click
();
ok
(
clickCounter
==
1
,
"Check that click, triggers onclick event handler on an a tag also"
);
});
test
(
"unbind(event)"
,
function
()
{
...
...
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