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
7f5179b6
Commit
7f5179b6
authored
Feb 26, 2010
by
jeresig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure that unbinding on a plain javascript object works correctly. Fixes #6184.
parent
28b489bf
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
2 deletions
+35
-2
event.js
src/event.js
+6
-2
event.js
test/unit/event.js
+29
-0
No files found.
src/event.js
View file @
7f5179b6
...
@@ -525,10 +525,14 @@ jQuery.event = {
...
@@ -525,10 +525,14 @@ jQuery.event = {
var removeEvent = document.removeEventListener ?
var removeEvent = document.removeEventListener ?
function( elem, type, handle ) {
function( elem, type, handle ) {
if ( elem.removeEventListener ) {
elem.removeEventListener( type, handle, false );
elem.removeEventListener( type, handle, false );
}
} :
} :
function( elem, type, handle ) {
function( elem, type, handle ) {
if ( elem.detachEvent ) {
elem.detachEvent( "
on
" + type, handle );
elem.detachEvent( "
on
" + type, handle );
}
};
};
jQuery.Event = function( src ) {
jQuery.Event = function( src ) {
...
...
test/unit/event.js
View file @
7f5179b6
...
@@ -373,6 +373,35 @@ test("bind(), with different this object", function() {
...
@@ -373,6 +373,35 @@ test("bind(), with different this object", function() {
ok
(
!
jQuery
.
data
(
jQuery
(
"#firstp"
)[
0
],
"events"
),
"Event handler unbound when using different this object and data."
);
ok
(
!
jQuery
.
data
(
jQuery
(
"#firstp"
)[
0
],
"events"
),
"Event handler unbound when using different this object and data."
);
});
});
test
(
"bind()/trigger()/unbind() on plain object"
,
function
()
{
expect
(
2
);
var
obj
=
{};
// Make sure it doesn't complain when no events are found
jQuery
(
obj
).
trigger
(
"test"
);
// Make sure it doesn't complain when no events are found
jQuery
(
obj
).
unbind
(
"test"
);
jQuery
(
obj
).
bind
(
"test"
,
function
(){
ok
(
true
,
"Custom event run."
);
});
ok
(
jQuery
(
obj
).
data
(
"events"
),
"Object has events bound."
);
// Should trigger 1
jQuery
(
obj
).
trigger
(
"test"
);
jQuery
(
obj
).
unbind
(
"test"
);
// Should trigger 0
jQuery
(
obj
).
trigger
(
"test"
);
// Make sure it doesn't complain when no events are found
jQuery
(
obj
).
unbind
(
"test"
);
});
test
(
"unbind(type)"
,
function
()
{
test
(
"unbind(type)"
,
function
()
{
expect
(
0
);
expect
(
0
);
...
...
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