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
390186b9
Commit
390186b9
authored
Jan 25, 2010
by
jeresig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure that special.add actually copies over event namespaces and data. Fixes #5779 and #5834.
parent
0474917c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
0 deletions
+43
-0
event.js
src/event.js
+2
-0
event.js
test/unit/event.js
+41
-0
No files found.
src/event.js
View file @
390186b9
...
...
@@ -114,6 +114,8 @@ jQuery.event = {
var modifiedHandler = special.add.call( elem, handler, data, namespaces, handlers );
if ( modifiedHandler && jQuery.isFunction( modifiedHandler ) ) {
modifiedHandler.guid = modifiedHandler.guid || handler.guid;
modifiedHandler.data = modifiedHandler.data || handler.data;
modifiedHandler.type = modifiedHandler.type || handler.type;
handler = modifiedHandler;
}
}
...
...
test/unit/event.js
View file @
390186b9
...
...
@@ -71,6 +71,47 @@ test("bind(), multiple events at once and namespaces", function() {
div
.
trigger
(
"focusout.b"
);
});
test
(
"bind(), namespace with special add"
,
function
()
{
expect
(
9
);
var
div
=
jQuery
(
"<div/>"
).
bind
(
"test"
,
function
(
e
)
{
ok
(
true
,
"Test event fired."
);
});
var
i
=
0
;
jQuery
.
event
.
special
.
test
=
{
setup
:
function
(){},
teardown
:
function
(){},
add
:
function
(
handler
,
data
,
namespaces
)
{
return
function
(
e
)
{
e
.
xyz
=
++
i
;
handler
.
apply
(
this
,
arguments
);
};
},
remove
:
function
()
{}
};
div
.
bind
(
"test.a"
,
{
x
:
1
},
function
(
e
)
{
ok
(
!!
e
.
xyz
,
"Make sure that the data is getting passed through."
);
equals
(
e
.
data
.
x
,
1
,
"Make sure data is attached properly."
);
});
div
.
bind
(
"test.b"
,
{
x
:
2
},
function
(
e
)
{
ok
(
!!
e
.
xyz
,
"Make sure that the data is getting passed through."
);
equals
(
e
.
data
.
x
,
2
,
"Make sure data is attached properly."
);
});
// Should trigger 5
div
.
trigger
(
"test"
);
// Should trigger 2
div
.
trigger
(
"test.a"
);
// Should trigger 2
div
.
trigger
(
"test.b"
);
});
test
(
"bind(), no data"
,
function
()
{
expect
(
1
);
var
handler
=
function
(
event
)
{
...
...
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