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
021b809a
Commit
021b809a
authored
Feb 11, 2010
by
John Resig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure that the teardown is called after all the handlers of a type are removed. Fixes #6065.
parent
639f4931
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
3 deletions
+7
-3
event.js
src/event.js
+1
-1
event.js
test/unit/event.js
+6
-2
No files found.
src/event.js
View file @
021b809a
...
@@ -221,7 +221,7 @@ jQuery.event = {
...
@@ -221,7 +221,7 @@ jQuery.event = {
}
}
// remove generic event handler if no more handlers exist
// remove generic event handler if no more handlers exist
if (
jQuery.isEmptyObject( events[ type ] )
) {
if (
eventType.length === 0 || pos != null && eventType.length === 1
) {
if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
removeEvent( elem, type, elemData.handle );
removeEvent( elem, type, elemData.handle );
}
}
...
...
test/unit/event.js
View file @
021b809a
...
@@ -72,7 +72,7 @@ test("bind(), multiple events at once and namespaces", function() {
...
@@ -72,7 +72,7 @@ test("bind(), multiple events at once and namespaces", function() {
});
});
test
(
"bind(), namespace with special add"
,
function
()
{
test
(
"bind(), namespace with special add"
,
function
()
{
expect
(
1
8
);
expect
(
1
9
);
var
div
=
jQuery
(
"<div/>"
).
bind
(
"test"
,
function
(
e
)
{
var
div
=
jQuery
(
"<div/>"
).
bind
(
"test"
,
function
(
e
)
{
ok
(
true
,
"Test event fired."
);
ok
(
true
,
"Test event fired."
);
...
@@ -87,7 +87,9 @@ test("bind(), namespace with special add", function() {
...
@@ -87,7 +87,9 @@ test("bind(), namespace with special add", function() {
equals
(
e
.
target
,
div
[
0
],
"And that the target is correct."
);
equals
(
e
.
target
,
div
[
0
],
"And that the target is correct."
);
},
},
setup
:
function
(){},
setup
:
function
(){},
teardown
:
function
(){},
teardown
:
function
(){
ok
(
true
,
"Teardown called."
);
},
add
:
function
(
handleObj
)
{
add
:
function
(
handleObj
)
{
var
handler
=
handleObj
.
handler
;
var
handler
=
handleObj
.
handler
;
handleObj
.
handler
=
function
(
e
)
{
handleObj
.
handler
=
function
(
e
)
{
...
@@ -116,6 +118,8 @@ test("bind(), namespace with special add", function() {
...
@@ -116,6 +118,8 @@ test("bind(), namespace with special add", function() {
// Should trigger 2
// Should trigger 2
div
.
trigger
(
"test.b"
);
div
.
trigger
(
"test.b"
);
div
.
unbind
(
"test"
);
});
});
test
(
"bind(), no data"
,
function
()
{
test
(
"bind(), no data"
,
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