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
78fc79fa
Commit
78fc79fa
authored
Feb 10, 2011
by
Anton M
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure .clone(true) correctly clones namespaced events. Fixes #4537.
parent
4490f428
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
7 deletions
+14
-7
manipulation.js
src/manipulation.js
+1
-1
event.js
test/unit/event.js
+13
-6
No files found.
src/manipulation.js
View file @
78fc79fa
...
@@ -368,7 +368,7 @@ function cloneCopyEvent( src, dest ) {
...
@@ -368,7 +368,7 @@ function cloneCopyEvent( src, dest ) {
for
(
var
type
in
events
)
{
for
(
var
type
in
events
)
{
for
(
var
i
=
0
,
l
=
events
[
type
].
length
;
i
<
l
;
i
++
)
{
for
(
var
i
=
0
,
l
=
events
[
type
].
length
;
i
<
l
;
i
++
)
{
jQuery
.
event
.
add
(
dest
,
type
,
events
[
type
][
i
],
events
[
type
][
i
].
data
);
jQuery
.
event
.
add
(
dest
,
type
+
(
events
[
type
][
i
].
namespace
?
"."
:
""
)
+
events
[
type
][
i
].
namespace
,
events
[
type
][
i
],
events
[
type
][
i
].
data
);
}
}
}
}
}
}
...
...
test/unit/event.js
View file @
78fc79fa
...
@@ -361,9 +361,7 @@ test("bind(), trigger change on select", function() {
...
@@ -361,9 +361,7 @@ test("bind(), trigger change on select", function() {
}).
trigger
(
'change'
);
}).
trigger
(
'change'
);
});
});
test
(
"bind(), namespaced events, cloned events"
,
function
()
{
test
(
"bind(), namespaced events, cloned events"
,
18
,
function
()
{
expect
(
6
);
var
firstp
=
jQuery
(
"#firstp"
);
var
firstp
=
jQuery
(
"#firstp"
);
firstp
.
bind
(
"custom.test"
,
function
(
e
){
firstp
.
bind
(
"custom.test"
,
function
(
e
){
...
@@ -372,22 +370,31 @@ test("bind(), namespaced events, cloned events", function() {
...
@@ -372,22 +370,31 @@ test("bind(), namespaced events, cloned events", function() {
firstp
.
bind
(
"click"
,
function
(
e
){
firstp
.
bind
(
"click"
,
function
(
e
){
ok
(
true
,
"Normal click triggered"
);
ok
(
true
,
"Normal click triggered"
);
equal
(
e
.
type
+
e
.
namespace
,
"click"
,
"Check that only click events trigger this fn"
);
});
});
firstp
.
bind
(
"click.test"
,
function
(
e
){
firstp
.
bind
(
"click.test"
,
function
(
e
){
var
check
=
"click"
;
ok
(
true
,
"Namespaced click triggered"
);
ok
(
true
,
"Namespaced click triggered"
);
if
(
e
.
namespace
)
{
check
+=
"test"
;
}
equal
(
e
.
type
+
e
.
namespace
,
check
,
"Check that only click/click.test events trigger this fn"
);
});
});
// Trigger both bound fn (2)
//clone(true) element to verify events are cloned correctly
firstp
=
firstp
.
add
(
firstp
.
clone
(
true
).
attr
(
"id"
,
"firstp2"
).
insertBefore
(
firstp
)
);
// Trigger both bound fn (8)
firstp
.
trigger
(
"click"
);
firstp
.
trigger
(
"click"
);
// Trigger one bound fn (
1
)
// Trigger one bound fn (
4
)
firstp
.
trigger
(
"click.test"
);
firstp
.
trigger
(
"click.test"
);
// Remove only the one fn
// Remove only the one fn
firstp
.
unbind
(
"click.test"
);
firstp
.
unbind
(
"click.test"
);
// Trigger the remaining fn (
1
)
// Trigger the remaining fn (
4
)
firstp
.
trigger
(
"click"
);
firstp
.
trigger
(
"click"
);
// Remove the remaining namespaced fn
// Remove the remaining namespaced fn
...
...
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