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
48164ee6
Commit
48164ee6
authored
Feb 23, 2009
by
Ariel Flesler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jquery event: Fixing event.currentTarget for live().
parent
883450b7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
event.js
src/event.js
+1
-0
event.js
test/unit/event.js
+12
-1
No files found.
src/event.js
View file @
48164ee6
...
@@ -577,6 +577,7 @@ function liveHandler( event ){
...
@@ -577,6 +577,7 @@ function liveHandler( event ){
});
});
jQuery
.
each
(
elems
,
function
(){
jQuery
.
each
(
elems
,
function
(){
event
.
currentTarget
=
this
.
elem
;
if
(
this
.
fn
.
call
(
this
.
elem
,
event
,
this
.
fn
.
data
)
===
false
)
if
(
this
.
fn
.
call
(
this
.
elem
,
event
,
this
.
fn
.
data
)
===
false
)
return
(
stop
=
false
);
return
(
stop
=
false
);
});
});
...
...
test/unit/event.js
View file @
48164ee6
...
@@ -489,7 +489,7 @@ test("toggle(Function, Function, ...)", function() {
...
@@ -489,7 +489,7 @@ test("toggle(Function, Function, ...)", function() {
});
});
test
(
".live()/.die()"
,
function
()
{
test
(
".live()/.die()"
,
function
()
{
expect
(
4
6
);
expect
(
4
9
);
var
submit
=
0
,
div
=
0
,
livea
=
0
,
liveb
=
0
;
var
submit
=
0
,
div
=
0
,
livea
=
0
,
liveb
=
0
;
...
@@ -649,6 +649,17 @@ test(".live()/.die()", function() {
...
@@ -649,6 +649,17 @@ test(".live()/.die()", function() {
// Cleanup
// Cleanup
jQuery
(
"span#liveSpan1 a, span#liveSpan1, span#liveSpan2 a, span#liveSpan2"
).
die
(
"click"
);
jQuery
(
"span#liveSpan1 a, span#liveSpan1, span#liveSpan2 a, span#liveSpan2"
).
die
(
"click"
);
// Test this, target and currentTarget are correct
jQuery
(
'span#liveSpan1'
).
live
(
'click'
,
function
(
e
){
equals
(
this
.
id
,
'liveSpan1'
,
'Check the this within a live handler'
);
equals
(
e
.
currentTarget
.
id
,
'liveSpan1'
,
'Check the event.currentTarget within a live handler'
);
equals
(
e
.
target
.
nodeName
.
toUpperCase
(),
'A'
,
'Check the event.target within a live handler'
);
});
jQuery
(
'span#liveSpan1 a'
).
click
();
jQuery
(
'span#liveSpan1'
).
die
(
'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