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
baa44a8f
Commit
baa44a8f
authored
Dec 23, 2006
by
John Resig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added in #690, the ability to remove an event handler from inside itself.
parent
c2092481
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
1 deletion
+20
-1
coreTest.js
src/jquery/coreTest.js
+13
-0
jquery.js
src/jquery/jquery.js
+7
-1
No files found.
src/jquery/coreTest.js
View file @
baa44a8f
...
@@ -564,3 +564,16 @@ test("removeClass(String) - add three classes and remove again", function() {
...
@@ -564,3 +564,16 @@ test("removeClass(String) - add three classes and remove again", function() {
test
(
"removeAttr(String"
,
function
()
{
test
(
"removeAttr(String"
,
function
()
{
ok
(
$
(
'#mark'
).
removeAttr
(
"class"
)[
0
].
className
==
""
,
"remove class"
);
ok
(
$
(
'#mark'
).
removeAttr
(
"class"
)[
0
].
className
==
""
,
"remove class"
);
});
});
test
(
"unbind(event)"
,
function
()
{
expect
(
3
);
var
el
=
$
(
"#firstp"
);
el
.
click
(
function
()
{
ok
(
true
,
"Fake normal bind"
);
});
el
.
click
(
function
(
event
)
{
el
.
unbind
(
event
);
ok
(
true
,
"Fake onebind"
);
});
el
.
click
().
click
();
});
src/jquery/jquery.js
View file @
baa44a8f
...
@@ -2090,7 +2090,9 @@ jQuery.extend({
...
@@ -2090,7 +2090,9 @@ jQuery.extend({
// Detach an event or set of events from an element
// Detach an event or set of events from an element
remove
:
function
(
element
,
type
,
handler
)
{
remove
:
function
(
element
,
type
,
handler
)
{
if
(
element
.
events
)
if
(
element
.
events
)
if
(
type
&&
element
.
events
[
type
])
if
(
type
&&
type
.
type
)
delete
element
.
events
[
type
.
type
][
type
.
handler
.
guid
];
else
if
(
type
&&
element
.
events
[
type
])
if
(
handler
)
if
(
handler
)
delete
element
.
events
[
type
][
handler
.
guid
];
delete
element
.
events
[
type
][
handler
.
guid
];
else
else
...
@@ -2135,6 +2137,10 @@ jQuery.extend({
...
@@ -2135,6 +2137,10 @@ jQuery.extend({
args
.
unshift
(
event
);
args
.
unshift
(
event
);
for
(
var
j
in
c
)
{
for
(
var
j
in
c
)
{
// Pass in a reference to the handler function itself
// So that we can later remove it
args
[
0
].
handler
=
c
[
j
];
if
(
c
[
j
].
apply
(
this
,
args
)
===
false
)
{
if
(
c
[
j
].
apply
(
this
,
args
)
===
false
)
{
event
.
preventDefault
();
event
.
preventDefault
();
event
.
stopPropagation
();
event
.
stopPropagation
();
...
...
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