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
bca82254
Commit
bca82254
authored
Sep 14, 2009
by
Ariel Flesler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jquery event: fixes #4989. blur and focus events now bubble and can be handled using live().
parent
f3474c00
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
2 deletions
+63
-2
event.js
src/event.js
+33
-2
event.js
test/unit/event.js
+30
-0
No files found.
src/event.js
View file @
bca82254
...
@@ -518,9 +518,10 @@ var withinElement = function( event ) {
...
@@ -518,9 +518,10 @@ var withinElement = function( event ) {
}
}
};
};
// Create mouseenter and mouseleave events
jQuery
.
each
({
jQuery
.
each
({
mouseover
:
'mouseenter'
,
mouseover
:
"mouseenter"
,
mouseout
:
'mouseleave'
mouseout
:
"mouseleave"
},
function
(
orig
,
fix
)
{
},
function
(
orig
,
fix
)
{
jQuery
.
event
.
special
[
fix
]
=
{
jQuery
.
event
.
special
[
fix
]
=
{
setup
:
function
(){
setup
:
function
(){
...
@@ -532,6 +533,36 @@ jQuery.each({
...
@@ -532,6 +533,36 @@ jQuery.each({
};
};
});
});
// Create "bubbling" focus and blur events
jQuery
.
each
({
focus
:
"focusin"
,
blur
:
"focusout"
},
function
(
orig
,
fix
){
var
event
=
jQuery
.
event
,
special
=
event
.
special
,
handle
=
event
.
handle
;
function
ieHandler
()
{
arguments
[
0
].
type
=
orig
;
return
handle
.
apply
(
this
,
arguments
);
}
special
[
orig
]
=
{
setup
:
function
()
{
if
(
this
.
addEventListener
)
this
.
addEventListener
(
orig
,
handle
,
true
);
else
jQuery
.
event
.
add
(
this
,
fix
,
ieHandler
);
},
teardown
:
function
()
{
if
(
this
.
removeEventListener
)
this
.
removeEventListener
(
orig
,
handle
,
true
);
else
jQuery
.
event
.
remove
(
this
,
fix
,
ieHandler
);
}
};
});
jQuery
.
fn
.
extend
({
jQuery
.
fn
.
extend
({
bind
:
function
(
type
,
data
,
fn
,
thisObject
)
{
bind
:
function
(
type
,
data
,
fn
,
thisObject
)
{
if
(
jQuery
.
isFunction
(
data
)
)
{
if
(
jQuery
.
isFunction
(
data
)
)
{
...
...
test/unit/event.js
View file @
bca82254
...
@@ -745,6 +745,36 @@ test(".live()/.die()", function() {
...
@@ -745,6 +745,36 @@ test(".live()/.die()", function() {
jQuery
(
'span#liveSpan1'
).
die
(
'click'
);
jQuery
(
'span#liveSpan1'
).
die
(
'click'
);
});
});
test
(
"live with focus/blur"
,
function
(){
expect
(
2
);
// Setup
jQuery
(
"<input type='text' id='livefb' />"
).
appendTo
(
"body"
);
var
$child
=
jQuery
(
"#livefb"
),
child
=
$child
[
0
],
counter
=
0
;
function
count
(){
counter
++
;
}
// Test
$child
.
live
(
"focus"
,
count
);
$child
.
live
(
"blur"
,
count
);
child
.
focus
();
equals
(
counter
,
1
,
"Test live() with focus event"
);
child
.
blur
();
equals
(
counter
,
2
,
"Test live() with blur event"
);
// Teardown
$child
.
die
(
"focus"
,
count
);
$child
.
die
(
"blur"
,
count
);
$child
.
remove
();
});
test
(
"Non DOM element events"
,
function
()
{
test
(
"Non DOM element events"
,
function
()
{
expect
(
3
);
expect
(
3
);
...
...
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