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
2897b1bd
Commit
2897b1bd
authored
Apr 24, 2007
by
Brandon Aaron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unbind handlers with data + test (#935)
parent
14aafdf3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
5 deletions
+12
-5
event.js
src/event/event.js
+4
-1
eventTest.js
src/event/eventTest.js
+8
-4
No files found.
src/event/event.js
View file @
2897b1bd
...
@@ -32,8 +32,11 @@ jQuery.event = {
...
@@ -32,8 +32,11 @@ jQuery.event = {
}
}
// Make sure that the function being executed has a unique ID
// Make sure that the function being executed has a unique ID
if
(
!
handler
.
guid
)
if
(
!
handler
.
guid
)
{
handler
.
guid
=
this
.
guid
++
;
handler
.
guid
=
this
.
guid
++
;
// Don't forget to set guid for the original handler function
if
(
fn
)
fn
.
guid
=
handler
.
guid
;
}
// Init the element's event structure
// Init the element's event structure
if
(
!
element
.
$events
)
if
(
!
element
.
$events
)
...
...
src/event/eventTest.js
View file @
2897b1bd
module
(
"event"
);
module
(
"event"
);
test
(
"bind()"
,
function
()
{
test
(
"bind()"
,
function
()
{
expect
(
1
1
);
expect
(
1
2
);
var
handler
=
function
(
event
)
{
var
handler
=
function
(
event
)
{
ok
(
event
.
data
,
"bind() with data, check passed data exists"
);
ok
(
event
.
data
,
"bind() with data, check passed data exists"
);
ok
(
event
.
data
.
foo
==
"bar"
,
"bind() with data, Check value of passed data"
);
ok
(
event
.
data
.
foo
==
"bar"
,
"bind() with data, Check value of passed data"
);
};
};
$
(
"#firstp"
).
bind
(
"click"
,
{
foo
:
"bar"
},
handler
).
click
();
$
(
"#firstp"
).
bind
(
"click"
,
{
foo
:
"bar"
},
handler
).
click
().
unbind
(
"click"
,
handler
);
ok
(
!
$
(
"#firstp"
).
get
(
0
).
$events
,
"Event handler unbound when using data."
);
reset
();
reset
();
var
handler
=
function
(
event
,
data
)
{
var
handler
=
function
(
event
,
data
)
{
...
@@ -16,12 +18,14 @@ test("bind()", function() {
...
@@ -16,12 +18,14 @@ test("bind()", function() {
ok
(
data
,
"Check trigger data"
);
ok
(
data
,
"Check trigger data"
);
ok
(
data
.
bar
==
"foo"
,
"Check value of trigger data"
);
ok
(
data
.
bar
==
"foo"
,
"Check value of trigger data"
);
};
};
$
(
"#firstp"
).
bind
(
"click"
,
{
foo
:
"bar"
},
handler
).
trigger
(
"click"
,
[{
bar
:
"foo"
}]);
$
(
"#firstp"
).
bind
(
"click"
,
{
foo
:
"bar"
},
handler
).
trigger
(
"click"
,
[{
bar
:
"foo"
}])
.
unbind
(
handler
)
;
reset
();
var
handler
=
function
(
event
)
{
var
handler
=
function
(
event
)
{
ok
(
!
event
.
data
,
"Check that no data is added to the event object"
);
ok
(
!
event
.
data
,
"Check that no data is added to the event object"
);
};
};
$
(
"#firstp"
).
unbind
().
bind
(
"click"
,
handler
).
trigger
(
"click"
);
$
(
"#firstp"
).
bind
(
"click"
,
handler
).
trigger
(
"click"
);
// events don't work with iframes, see #939
// events don't work with iframes, see #939
var
tmp
=
document
.
createElement
(
'iframe'
);
var
tmp
=
document
.
createElement
(
'iframe'
);
...
...
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