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
612a9085
Commit
612a9085
authored
Jan 01, 2011
by
rwldrn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#7883 .delegate and .live should accept false as the fn arg, like bind
parent
eed3803c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
1 deletion
+45
-1
event.js
src/event.js
+6
-1
event.js
test/unit/event.js
+39
-0
No files found.
src/event.js
View file @
612a9085
...
@@ -1023,11 +1023,16 @@ jQuery.each(["live", "die"], function( i, name ) {
...
@@ -1023,11 +1023,16 @@ jQuery.each(["live", "die"], function( i, name ) {
return
this
;
return
this
;
}
}
if
(
jQuery
.
isFunction
(
data
)
)
{
if
(
jQuery
.
isFunction
(
data
)
||
data
===
false
)
{
fn
=
data
;
fn
=
data
;
data
=
undefined
;
data
=
undefined
;
}
}
if
(
fn
===
false
)
{
fn
=
returnFalse
;
}
types
=
(
types
||
""
).
split
(
" "
);
types
=
(
types
||
""
).
split
(
" "
);
while
(
(
type
=
types
[
i
++
])
!=
null
)
{
while
(
(
type
=
types
[
i
++
])
!=
null
)
{
...
...
test/unit/event.js
View file @
612a9085
...
@@ -527,6 +527,45 @@ test("bind(name, false), unbind(name, false)", function() {
...
@@ -527,6 +527,45 @@ test("bind(name, false), unbind(name, false)", function() {
equals
(
main
,
1
,
"Verify that the trigger happened correctly."
);
equals
(
main
,
1
,
"Verify that the trigger happened correctly."
);
});
});
test
(
"live(name, false), die(name, false)"
,
function
()
{
expect
(
3
);
var
main
=
0
;
jQuery
(
"#main"
).
live
(
"click"
,
function
(
e
){
main
++
;
});
jQuery
(
"#ap"
).
trigger
(
"click"
);
equals
(
main
,
1
,
"Verify that the trigger happened correctly."
);
main
=
0
;
jQuery
(
"#ap"
).
live
(
"click"
,
false
);
jQuery
(
"#ap"
).
trigger
(
"click"
);
equals
(
main
,
0
,
"Verify that no bubble happened."
);
main
=
0
;
jQuery
(
"#ap"
).
die
(
"click"
,
false
);
jQuery
(
"#ap"
).
trigger
(
"click"
);
equals
(
main
,
1
,
"Verify that the trigger happened correctly."
);
});
test
(
"delegate(selector, name, false), undelegate(selector, name, false)"
,
function
()
{
expect
(
3
);
var
main
=
0
;
jQuery
(
"#main"
).
delegate
(
"#ap"
,
"click"
,
function
(
e
){
main
++
;
});
jQuery
(
"#ap"
).
trigger
(
"click"
);
equals
(
main
,
1
,
"Verify that the trigger happened correctly."
);
main
=
0
;
jQuery
(
"#ap"
).
delegate
(
"#groups"
,
"click"
,
false
);
jQuery
(
"#groups"
).
trigger
(
"click"
);
equals
(
main
,
0
,
"Verify that no bubble happened."
);
main
=
0
;
jQuery
(
"#ap"
).
undelegate
(
"#groups"
,
"click"
,
false
);
jQuery
(
"#groups"
).
trigger
(
"click"
);
equals
(
main
,
1
,
"Verify that the trigger happened correctly."
);
});
test
(
"bind()/trigger()/unbind() on plain object"
,
function
()
{
test
(
"bind()/trigger()/unbind() on plain object"
,
function
()
{
expect
(
8
);
expect
(
8
);
...
...
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