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
da5706c9
Commit
da5706c9
authored
Mar 14, 2010
by
Robert Katic
Committed by
jeresig
Sep 23, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for map of events in live, die, delegate and undelegate. Fixes #6282.
parent
97b42492
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
0 deletions
+47
-0
event.js
src/event.js
+8
-0
event.js
test/unit/event.js
+39
-0
No files found.
src/event.js
View file @
da5706c9
...
@@ -945,6 +945,14 @@ jQuery.each(["live", "die"], function( i, name ) {
...
@@ -945,6 +945,14 @@ jQuery.each(["live", "die"], function( i, name ) {
selector
=
origSelector
||
this
.
selector
,
selector
=
origSelector
||
this
.
selector
,
context
=
origSelector
?
this
:
jQuery
(
this
.
context
);
context
=
origSelector
?
this
:
jQuery
(
this
.
context
);
if
(
typeof
types
===
"object"
&&
!
types
.
preventDefault
)
{
for
(
var
key
in
types
)
{
context
[
name
](
key
,
data
,
types
[
key
],
selector
);
}
return
this
;
}
if
(
jQuery
.
isFunction
(
data
)
)
{
if
(
jQuery
.
isFunction
(
data
)
)
{
fn
=
data
;
fn
=
data
;
data
=
undefined
;
data
=
undefined
;
...
...
test/unit/event.js
View file @
da5706c9
...
@@ -206,6 +206,45 @@ test("bind/one/unbind(Object)", function(){
...
@@ -206,6 +206,45 @@ test("bind/one/unbind(Object)", function(){
equals
(
mouseoverCounter
,
4
,
"bind(Object)"
);
equals
(
mouseoverCounter
,
4
,
"bind(Object)"
);
});
});
test
(
"live/die(Object), delegate/undelegate(String, Object)"
,
function
()
{
expect
(
6
);
var
clickCounter
=
0
,
mouseoverCounter
=
0
,
$p
=
jQuery
(
"#firstp"
),
$a
=
$p
.
find
(
"a"
);
var
events
=
{
click
:
function
(
event
)
{
clickCounter
+=
(
event
.
data
||
1
);
},
mouseover
:
function
(
event
)
{
mouseoverCounter
+=
(
event
.
data
||
1
);
}
};
function
trigger
()
{
$a
.
trigger
(
"click"
).
trigger
(
"mouseover"
);
}
$a
.
live
(
events
);
$p
.
delegate
(
"a"
,
events
,
2
);
trigger
();
equals
(
clickCounter
,
3
,
"live/delegate(Object)"
);
equals
(
mouseoverCounter
,
3
,
"live/delegate(Object)"
);
$p
.
undelegate
(
"a"
,
events
);
trigger
();
equals
(
clickCounter
,
4
,
"undelegate(Object)"
);
equals
(
mouseoverCounter
,
4
,
"undelegate(Object)"
);
$a
.
die
(
events
);
trigger
();
equals
(
clickCounter
,
4
,
"die(Object)"
);
equals
(
mouseoverCounter
,
4
,
"die(Object)"
);
});
test
(
"bind(), iframes"
,
function
()
{
test
(
"bind(), iframes"
,
function
()
{
// events don't work with iframes, see #939 - this test fails in IE because of contentDocument
// events don't work with iframes, see #939 - this test fails in IE because of contentDocument
var
doc
=
jQuery
(
"#loadediframe"
).
contents
();
var
doc
=
jQuery
(
"#loadediframe"
).
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