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
fdaf2146
Commit
fdaf2146
authored
Apr 09, 2013
by
Dave Methvin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #13393. Avoid IE9 activeElement of death.
(Cherry picked from
85fc5878
) Conflicts: src/event.js
parent
08e57b1d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
2 deletions
+29
-2
event.js
src/event.js
+8
-2
focusElem.html
test/data/event/focusElem.html
+16
-0
event.js
test/unit/event.js
+5
-0
No files found.
src/event.js
View file @
fdaf2146
...
...
@@ -12,6 +12,12 @@ function returnFalse() {
return
false
;
}
function
safeActiveElement
()
{
try
{
return
document
.
activeElement
;
}
catch
(
err
)
{
}
}
/*
* Helper functions for managing events -- not part of the public interface.
* Props to Dean Edwards' addEvent library for many of the ideas.
...
...
@@ -555,7 +561,7 @@ jQuery.event = {
focus
:
{
// Fire native event if possible so blur/focus sequence is correct
trigger
:
function
()
{
if
(
this
!==
document
.
activeElement
&&
this
.
focus
)
{
if
(
this
!==
safeActiveElement
()
&&
this
.
focus
)
{
try
{
this
.
focus
();
return
false
;
...
...
@@ -570,7 +576,7 @@ jQuery.event = {
},
blur
:
{
trigger
:
function
()
{
if
(
this
===
document
.
activeElement
&&
this
.
blur
)
{
if
(
this
===
safeActiveElement
()
&&
this
.
blur
)
{
this
.
blur
();
return
false
;
}
...
...
test/data/event/focusElem.html
0 → 100644
View file @
fdaf2146
<!doctype html>
<html>
<head>
<meta
http-equiv=
"Content-type"
content=
"text/html; charset=utf-8"
>
<title>
.focus() (activeElement access #13393)
</title>
<script
src=
"../../jquery.js"
></script>
</head>
<body>
<a
href=
"#"
id=
"frame-link"
></a>
<script>
jQuery
(
"#frame-link"
).
focus
();
window
.
parent
.
iframeCallback
(
true
);
</script>
</body>
</html>
\ No newline at end of file
test/unit/event.js
View file @
fdaf2146
...
...
@@ -2489,6 +2489,11 @@ testIframeWithCallback( "jQuery.ready promise", "event/promiseReady.html", funct
ok
(
isOk
,
"$.when( $.ready ) works"
);
});
testIframeWithCallback
(
"Focusing iframe element"
,
"event/focusElem.html"
,
function
(
isOk
)
{
expect
(
1
);
ok
(
isOk
,
"Focused an element in an iframe"
);
});
// need PHP here to make the incepted IFRAME hang
if
(
hasPHP
)
{
testIframeWithCallback
(
"jQuery.ready synchronous load with long loading subresources"
,
"event/syncReady.html"
,
function
(
isOk
)
{
...
...
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