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
34cb5b58
Commit
34cb5b58
authored
Feb 25, 2007
by
Brandon Aaron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for #964
parent
b15ae79a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
7 deletions
+30
-7
ChangeLog.txt
ChangeLog.txt
+1
-0
event.js
src/event/event.js
+24
-6
eventTest.js
src/event/eventTest.js
+5
-1
No files found.
ChangeLog.txt
View file @
34cb5b58
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
=== 1.1.2 ===
=== 1.1.2 ===
* Event handlers (like element.onclick) are now removed when no more functions are bound to the event.
* Fixed DOM Manipulations for form elements.
* Fixed DOM Manipulations for form elements.
* Fixed jQuery.isFunction to return false on nodes.
* Fixed jQuery.isFunction to return false on nodes.
* Fixed jQuery.className.has, escaping regex characters in className (for metadata)
* Fixed jQuery.className.has, escaping regex characters in className (for metadata)
...
...
src/event/event.js
View file @
34cb5b58
...
@@ -55,18 +55,36 @@ jQuery.event = {
...
@@ -55,18 +55,36 @@ jQuery.event = {
// 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
&&
type
.
type
)
var
i
,
j
,
k
;
delete
element
.
$events
[
type
.
type
][
type
.
handler
.
guid
];
if
(
type
&&
type
.
type
)
{
// type is actually an event object here
else
if
(
type
&&
element
.
$events
[
type
])
handler
=
type
.
handler
;
type
=
type
.
type
;
}
if
(
type
&&
element
.
$events
[
type
])
// remove the given handler for the given type
if
(
handler
)
if
(
handler
)
delete
element
.
$events
[
type
][
handler
.
guid
];
delete
element
.
$events
[
type
][
handler
.
guid
];
// remove all handlers for the given type
else
else
for
(
var
i
in
element
.
$events
[
type
]
)
for
(
i
in
element
.
$events
[
type
]
)
delete
element
.
$events
[
type
][
i
];
delete
element
.
$events
[
type
][
i
];
// remove all handlers
else
else
for
(
var
j
in
element
.
$events
)
for
(
j
in
element
.
$events
)
this
.
remove
(
element
,
j
);
this
.
remove
(
element
,
j
);
// remove event handler if no more handlers exist
for
(
k
in
element
.
$events
[
type
]
)
if
(
k
)
{
k
=
true
;
break
;
}
if
(
!
k
)
element
[
"on"
+
type
]
=
null
;
}
},
},
trigger
:
function
(
type
,
data
,
element
)
{
trigger
:
function
(
type
,
data
,
element
)
{
...
...
src/event/eventTest.js
View file @
34cb5b58
...
@@ -15,7 +15,7 @@ test("toggle(Function, Function) - add toggle event and fake a few clicks", func
...
@@ -15,7 +15,7 @@ test("toggle(Function, Function) - add toggle event and fake a few clicks", func
});
});
test
(
"unbind(event)"
,
function
()
{
test
(
"unbind(event)"
,
function
()
{
expect
(
3
);
expect
(
4
);
var
el
=
$
(
"#firstp"
);
var
el
=
$
(
"#firstp"
);
el
.
click
(
function
()
{
el
.
click
(
function
()
{
ok
(
true
,
"Fake normal bind"
);
ok
(
true
,
"Fake normal bind"
);
...
@@ -25,6 +25,10 @@ test("unbind(event)", function() {
...
@@ -25,6 +25,10 @@ test("unbind(event)", function() {
ok
(
true
,
"Fake onebind"
);
ok
(
true
,
"Fake onebind"
);
});
});
el
.
click
().
click
();
el
.
click
().
click
();
el
.
click
(
function
()
{
return
;
});
el
.
unbind
(
'click'
);
ok
(
!
el
[
0
].
onclick
,
"Handler is removed"
);
// Bug #964
});
});
test
(
"trigger(event, [data]"
,
function
()
{
test
(
"trigger(event, [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