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
a9c2a9bf
Commit
a9c2a9bf
authored
Aug 23, 2012
by
Mike Sherov
Committed by
Dave Methvin
Aug 24, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Scorch the earth and retreat on readyState interactive! Close gh-907.
parent
10901f7d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
137 deletions
+13
-137
core.js
src/core.js
+2
-2
asyncReady.html
test/data/event/asyncReady.html
+0
-30
longLoad.php
test/data/event/longLoad.php
+0
-6
partialLoadReady.php
test/data/event/partialLoadReady.php
+0
-40
syncReadyLongLoad.html
test/data/event/syncReadyLongLoad.html
+0
-26
event.js
test/unit/event.js
+11
-33
No files found.
src/core.js
View file @
a9c2a9bf
...
@@ -831,9 +831,9 @@ jQuery.ready.promise = function( obj ) {
...
@@ -831,9 +831,9 @@ jQuery.ready.promise = function( obj ) {
readyList
=
jQuery
.
Deferred
();
readyList
=
jQuery
.
Deferred
();
// Catch cases where $(document).ready() is called after the browser event has already occurred.
// Catch cases where $(document).ready() is called after the browser event has already occurred.
//
IE10 and lower don't handle "interactive" properly... use a weak inference to detect it
//
we once tried to use readyState "interactive" here, but it caused issues like the one
// discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
// discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
if
(
document
.
attachEvent
?
document
.
readyState
===
"complete"
:
document
.
readyState
!==
"loading
"
)
{
if
(
document
.
readyState
===
"complete
"
)
{
// Handle it asynchronously to allow scripts the opportunity to delay ready
// Handle it asynchronously to allow scripts the opportunity to delay ready
setTimeout
(
jQuery
.
ready
,
1
);
setTimeout
(
jQuery
.
ready
,
1
);
...
...
test/data/event/asyncReady.html
deleted
100644 → 0
View file @
10901f7d
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta
http-equiv=
"content-type"
content=
"text/html; charset=utf-8"
>
<title>
Test case for jQuery ticket #10067
</title>
<script
type=
"text/javascript"
>
setTimeout
(
function
()
{
el
=
document
.
createElement
(
"script"
);
el
.
type
=
"text/javascript"
;
el
.
onload
=
function
()
{
jQuery
(
document
).
ready
(
function
()
{
window
.
parent
.
iframeCallback
(
jQuery
(
'#container'
).
length
===
1
);
});
}
document
.
getElementsByTagName
(
"head"
)[
0
].
appendChild
(
el
);
el
.
src
=
"../../../dist/jquery.js"
;
},
1000
);
</script>
</head>
<body>
<!-- external resources that come before elements trick
oldIE into thinking the dom is ready, but it's not... -->
<script
type=
"text/javascript"
src=
"longLoadScript.php?sleep=1"
></script>
<div
id=
"container"
style=
"height: 300px"
></div>
<!-- long loading iframe -->
<iframe
src=
"longLoad.php?sleep=15&return=false"
style=
"width: 1px; height: 1px"
></iframe>
</body>
</html>
test/data/event/longLoad.php
deleted
100644 → 0
View file @
10901f7d
<?php
sleep
((
int
)
$_GET
[
'sleep'
]);
?>
<script
type=
"text/javascript"
>
window
.
parent
.
parent
.
iframeCallback
(
<?php
echo
$_GET
[
'return'
];
?>
);
</script>
\ No newline at end of file
test/data/event/partialLoadReady.php
deleted
100644 → 0
View file @
10901f7d
<?php
//try very hard to disable output buffering
//@ini_set("output_buffering", 0);
//@apache_setenv("no-gzip", 1);
//@ini_set("zlib.output_compression", 0);
ob_start
();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta
http-equiv=
"content-type"
content=
"text/html; charset=utf-8"
>
<title>
Test case for jQuery ticket #12282
</title>
</head>
<body>
<h1>
TEST
</h1>
<script
type=
"text/javascript"
src=
"../../../dist/jquery.js"
></script>
<script
type=
"text/javascript"
>
jQuery
(
document
).
ready
(
function
()
{
window
.
parent
.
iframeCallback
(
jQuery
(
'#container'
).
length
===
1
);
});
</script>
<?php
//send the top of the document without sending the bottom portion
echo
str_repeat
(
" "
,
1024
*
8
),
"
\n
"
;
ob_flush
();
?>
<h2>
Sleeping for 1 seconds (simulating server side process)
</h2>
<?php
//sleep for a bit, simulating a server side process
sleep
(
1
);
?>
<div
id=
"container"
>
ready
</h2>
</body>
</html>
\ No newline at end of file
test/data/event/syncReadyLongLoad.html
deleted
100644 → 0
View file @
10901f7d
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta
http-equiv=
"content-type"
content=
"text/html; charset=utf-8"
>
<title>
Test case for jQuery ticket #10067
</title>
<script
type=
"text/javascript"
src=
"../../../dist/jquery.js"
></script>
</head>
<body>
<script
type=
"text/javascript"
>
jQuery
(
document
).
ready
(
function
()
{
window
.
parent
.
iframeCallback
(
jQuery
(
'#container'
).
length
===
1
);
});
</script>
<!-- external resources that come before elements trick
oldIE into thinking the dom is ready, but it's not...
leaving this check here for future trailblazers to attempt
fixing this...-->
<script
type=
"text/javascript"
src=
"longLoadScript.php?sleep=1"
></script>
<div
id=
"container"
style=
"height: 300px"
></div>
<!-- long loading iframe -->
<iframe
src=
"longLoad.php?sleep=10&return=false"
style=
"width: 1px; height: 1px"
></iframe>
</body>
</html>
test/unit/event.js
View file @
a9c2a9bf
...
@@ -2882,39 +2882,17 @@ test("fixHooks extensions", function() {
...
@@ -2882,39 +2882,17 @@ test("fixHooks extensions", function() {
jQuery
.
event
.
fixHooks
.
click
=
saved
;
jQuery
.
event
.
fixHooks
.
click
=
saved
;
});
});
testIframeWithCallback
(
"jQuery.ready promise"
,
"event/promiseReady.html"
,
function
(
isOk
)
{
expect
(
1
);
ok
(
isOk
,
"$.when( $.ready ) works"
);
});
// async loaded tests expect jQuery to be loaded as a single file
// need PHP here to make the incepted IFRAME hang
// if we're not doing PHP concat, then we fall back to document.write
// which breaks order of execution on async loaded files
// also need PHP to make the incepted IFRAME hang
if
(
hasPHP
)
{
if
(
hasPHP
)
{
testIframeWithCallback
(
"jQuery.ready promise"
,
"event/promiseReady.html"
,
function
(
isOk
)
{
expect
(
1
);
ok
(
isOk
,
"$.when( $.ready ) works"
);
});
testIframeWithCallback
(
"jQuery.ready synchronous load with long loading subresources"
,
"event/syncReady.html"
,
function
(
isOk
)
{
testIframeWithCallback
(
"jQuery.ready synchronous load with long loading subresources"
,
"event/syncReady.html"
,
function
(
isOk
)
{
expect
(
1
);
expect
(
1
);
ok
(
isOk
,
"jQuery loaded synchronously fires ready when the DOM can truly be interacted with"
);
ok
(
isOk
,
"jQuery loaded synchronously fires ready when the DOM can truly be interacted with"
);
});
});
testIframeWithCallback
(
"jQuery.ready synchronous load with partially loaded page"
,
"event/partialLoadReady.php"
,
function
(
isOk
)
{
expect
(
1
);
ok
(
isOk
,
"jQuery loaded synchronously fires ready when the DOM can truly be interacted with"
);
});
// allIE needs all subresources and full page to be loaded before it can gaurantee the document is truly ready to be interacted with
if
(
!
document
.
attachEvent
)
{
testIframeWithCallback
(
"jQuery.ready synchronous load with long loading iframe"
,
"event/syncReadyLongLoad.html"
,
function
(
isOk
)
{
expect
(
1
);
ok
(
isOk
,
"jQuery loaded synchronously fires ready before all sub-resources are loaded"
);
});
testIframeWithCallback
(
"jQuery.ready asynchronous load with long loading iframe"
,
"event/asyncReady.html"
,
function
(
isOk
)
{
expect
(
1
);
ok
(
isOk
,
"jQuery loaded asynchronously fires ready before all sub-resources are loaded"
);
});
}
}
}
(
function
(){
(
function
(){
...
@@ -2994,22 +2972,22 @@ test("change handler should be detached from element", function() {
...
@@ -2994,22 +2972,22 @@ test("change handler should be detached from element", function() {
expect
(
2
);
expect
(
2
);
var
$fixture
=
jQuery
(
"<input type='text' id='change-ie-leak' />"
).
appendTo
(
"body"
);
var
$fixture
=
jQuery
(
"<input type='text' id='change-ie-leak' />"
).
appendTo
(
"body"
);
var
originRemoveEvent
=
jQuery
.
removeEvent
;
var
originRemoveEvent
=
jQuery
.
removeEvent
;
var
wrapperRemoveEvent
=
function
(
elem
,
type
,
handle
){
var
wrapperRemoveEvent
=
function
(
elem
,
type
,
handle
){
equal
(
"change"
,
type
,
"Event handler for 'change' event should be removed"
);
equal
(
"change"
,
type
,
"Event handler for 'change' event should be removed"
);
equal
(
"change-ie-leak"
,
jQuery
(
elem
).
attr
(
"id"
),
"Event handler for 'change' event should be removed from appropriate element"
);
equal
(
"change-ie-leak"
,
jQuery
(
elem
).
attr
(
"id"
),
"Event handler for 'change' event should be removed from appropriate element"
);
originRemoveEvent
(
elem
,
type
,
handle
);
originRemoveEvent
(
elem
,
type
,
handle
);
};
};
jQuery
.
removeEvent
=
wrapperRemoveEvent
;
jQuery
.
removeEvent
=
wrapperRemoveEvent
;
$fixture
.
bind
(
"change"
,
function
(
event
)
{});
$fixture
.
bind
(
"change"
,
function
(
event
)
{});
$fixture
.
unbind
(
"change"
);
$fixture
.
unbind
(
"change"
);
$fixture
.
remove
();
$fixture
.
remove
();
jQuery
.
removeEvent
=
originRemoveEvent
;
jQuery
.
removeEvent
=
originRemoveEvent
;
});
});
...
...
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