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
851846aa
Commit
851846aa
authored
Apr 29, 2009
by
Brandon Aaron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.unbind() without any arguments now also unbinds namespaced events. fixes #4609 and #4241
parent
1bd4325c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
4 deletions
+10
-4
event.js
src/event.js
+3
-2
event.js
test/unit/event.js
+7
-2
No files found.
src/event.js
View file @
851846aa
...
...
@@ -116,7 +116,8 @@ jQuery.event = {
// Namespaced event handlers
var
namespaces
=
type
.
split
(
"."
);
type
=
namespaces
.
shift
();
var
namespace
=
new
RegExp
(
"(^|
\\
.)"
+
namespaces
.
slice
().
sort
().
join
(
".*
\\
."
)
+
"(
\\
.|$)"
);
var
all
=
!
namespaces
.
length
,
namespace
=
new
RegExp
(
"(^|
\\
.)"
+
namespaces
.
slice
().
sort
().
join
(
".*
\\
."
)
+
"(
\\
.|$)"
);
if
(
events
[
type
]
)
{
// remove the given handler for the given type
...
...
@@ -127,7 +128,7 @@ jQuery.event = {
else
for
(
var
handle
in
events
[
type
]
)
// Handle the removal of namespaced events
if
(
namespace
.
test
(
events
[
type
][
handle
].
type
)
)
if
(
all
||
namespace
.
test
(
events
[
type
][
handle
].
type
)
)
delete
events
[
type
][
handle
];
if
(
jQuery
.
event
.
specialAll
[
type
]
)
...
...
test/unit/event.js
View file @
851846aa
...
...
@@ -194,6 +194,11 @@ test("unbind(type)", function() {
$elem
.
bind
(
'error error2'
,
error
)
.
unbind
(
'error error2'
)
.
trigger
(
'error'
).
triggerHandler
(
'error2'
);
message
=
"unbind without a type or handler"
;
$elem
.
bind
(
"error error2.test"
,
error
)
.
unbind
()
.
trigger
(
"error"
).
triggerHandler
(
"error2"
);
});
test
(
"unbind(eventObject)"
,
function
()
{
...
...
@@ -651,14 +656,14 @@ test(".live()/.die()", function() {
// bind one pair in one order
jQuery
(
'span#liveSpan1 a'
).
live
(
'click'
,
function
(){
lived
++
;
return
false
;
});
jQuery
(
'span#liveSpan1'
).
live
(
'click'
,
function
(){
livee
++
;
});
jQuery
(
'span#liveSpan1'
).
live
(
'click'
,
function
(){
livee
++
;
});
jQuery
(
'span#liveSpan1 a'
).
click
();
equals
(
lived
,
1
,
"Verify that only one first handler occurred."
);
equals
(
livee
,
0
,
"Verify that second handler don't."
);
// and one pair in inverse
jQuery
(
'#liveHandlerOrder span#liveSpan2'
).
live
(
'click'
,
function
(){
livee
++
;
});
jQuery
(
'#liveHandlerOrder span#liveSpan2'
).
live
(
'click'
,
function
(){
livee
++
;
});
jQuery
(
'#liveHandlerOrder span#liveSpan2 a'
).
live
(
'click'
,
function
(){
lived
++
;
return
false
;
});
jQuery
(
'span#liveSpan2 a'
).
click
();
...
...
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