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
1cecf64e
Commit
1cecf64e
authored
Sep 17, 2013
by
Dave Methvin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #14180. Allow cross-frame use of focusin/out. Close gh-1369.
parent
b7f62abb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
7 deletions
+68
-7
event.js
src/event.js
+17
-7
focusinCrossFrame.html
test/data/event/focusinCrossFrame.html
+18
-0
event.js
test/unit/event.js
+33
-0
No files found.
src/event.js
View file @
1cecf64e
...
@@ -726,21 +726,31 @@ jQuery.each({
...
@@ -726,21 +726,31 @@ jQuery.each({
if
(
!
support
.
focusinBubbles
)
{
if
(
!
support
.
focusinBubbles
)
{
jQuery
.
each
({
focus
:
"focusin"
,
blur
:
"focusout"
},
function
(
orig
,
fix
)
{
jQuery
.
each
({
focus
:
"focusin"
,
blur
:
"focusout"
},
function
(
orig
,
fix
)
{
// Attach a single capturing handler while someone wants focusin/focusout
// Attach a single capturing handler on the document while someone wants focusin/focusout
var
attaches
=
0
,
var
handler
=
function
(
event
)
{
handler
=
function
(
event
)
{
jQuery
.
event
.
simulate
(
fix
,
event
.
target
,
jQuery
.
event
.
fix
(
event
),
true
);
jQuery
.
event
.
simulate
(
fix
,
event
.
target
,
jQuery
.
event
.
fix
(
event
),
true
);
};
};
jQuery
.
event
.
special
[
fix
]
=
{
jQuery
.
event
.
special
[
fix
]
=
{
setup
:
function
()
{
setup
:
function
()
{
if
(
attaches
++
===
0
)
{
var
doc
=
this
.
ownerDocument
,
document
.
addEventListener
(
orig
,
handler
,
true
);
attaches
=
data_priv
.
access
(
doc
,
fix
);
if
(
!
attaches
)
{
doc
.
addEventListener
(
orig
,
handler
,
true
);
}
}
data_priv
.
access
(
doc
,
fix
,
(
attaches
||
0
)
+
1
);
},
},
teardown
:
function
()
{
teardown
:
function
()
{
if
(
--
attaches
===
0
)
{
var
doc
=
this
.
ownerDocument
,
document
.
removeEventListener
(
orig
,
handler
,
true
);
attaches
=
data_priv
.
access
(
doc
,
fix
)
-
1
;
if
(
!
attaches
)
{
doc
.
removeEventListener
(
orig
,
handler
,
true
);
data_priv
.
remove
(
doc
,
fix
);
}
else
{
data_priv
.
access
(
doc
,
fix
,
attaches
);
}
}
}
}
};
};
...
...
test/data/event/focusinCrossFrame.html
0 → 100644
View file @
1cecf64e
<!doctype html>
<html>
<head>
<meta
http-equiv=
"Content-type"
content=
"text/html; charset=utf-8"
>
<title>
focusin event cross-frame (#14180)
</title>
<script
src=
"../../jquery.js"
></script>
</head>
<body>
<input
type=
"text"
id=
"frame-input"
/>
<script>
// Call parent when this frame is fully loaded, it will mess with #frame-input
jQuery
(
window
).
one
(
"load"
,
function
()
{
window
.
parent
.
iframeCallback
(
document
);
});
</script>
</body>
</html>
test/unit/event.js
View file @
1cecf64e
...
@@ -2374,6 +2374,39 @@ test("fixHooks extensions", function() {
...
@@ -2374,6 +2374,39 @@ test("fixHooks extensions", function() {
jQuery
.
event
.
fixHooks
.
click
=
saved
;
jQuery
.
event
.
fixHooks
.
click
=
saved
;
});
});
testIframeWithCallback
(
"focusin from an iframe"
,
"event/focusinCrossFrame.html"
,
function
(
frameDoc
)
{
expect
(
1
);
var
input
=
jQuery
(
frameDoc
).
find
(
"#frame-input"
);
if
(
input
.
length
)
{
// Create a focusin handler on the parent; shouldn't affect the iframe's fate
jQuery
(
"body"
).
on
(
"focusin.iframeTest"
,
function
()
{
ok
(
false
,
"fired a focusin event in the parent document"
);
});
input
.
on
(
"focusin"
,
function
()
{
ok
(
true
,
"fired a focusin event in the iframe"
);
});
// Avoid a native event; Chrome can't force focus to another frame
input
.
trigger
(
"focusin"
);
// Must manually remove handler to avoid leaks in our data store
input
.
remove
();
// Be sure it was removed; nothing should happen
input
.
trigger
(
"focusin"
);
// Remove body handler manually since it's outside the fixture
jQuery
(
"body"
).
off
(
"focusin.iframeTest"
);
}
else
{
// Opera 12 (pre-Blink) doesn't select anything
ok
(
true
,
"SOFTFAIL: no focus event fired in the iframe"
);
}
});
testIframeWithCallback
(
"jQuery.ready promise"
,
"event/promiseReady.html"
,
function
(
isOk
)
{
testIframeWithCallback
(
"jQuery.ready promise"
,
"event/promiseReady.html"
,
function
(
isOk
)
{
expect
(
1
);
expect
(
1
);
ok
(
isOk
,
"$.when( $.ready ) works"
);
ok
(
isOk
,
"$.when( $.ready ) works"
);
...
...
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