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
0f553ed0
Commit
0f553ed0
authored
Aug 19, 2012
by
Mike Sherov
Committed by
Dave Methvin
Aug 20, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #12282. IE has premature .readyState == "interactive". Close gh-901.
parent
f3ea073d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
62 additions
and
16 deletions
+62
-16
core.js
src/core.js
+4
-3
partialLoadReady.php
test/data/event/partialLoadReady.php
+40
-0
testinit.js
test/data/testinit.js
+1
-1
event.js
test/unit/event.js
+15
-10
support.js
test/unit/support.js
+2
-2
No files found.
src/core.js
View file @
0f553ed0
...
@@ -830,9 +830,10 @@ jQuery.ready.promise = function( obj ) {
...
@@ -830,9 +830,10 @@ jQuery.ready.promise = function( obj ) {
readyList
=
jQuery
.
Deferred
();
readyList
=
jQuery
.
Deferred
();
// Catch cases where $(document).ready() is called after the
// Catch cases where $(document).ready() is called after the browser event has already occurred.
// browser event has already occurred.
// IE10 and lower don't handle "interactive" properly... use a weak inference to detect it
if
(
document
.
readyState
===
"complete"
||
(
document
.
readyState
!==
"loading"
&&
document
.
addEventListener
)
)
{
// discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
if
(
document
.
attachEvent
?
document
.
readyState
===
"complete"
:
document
.
readyState
!==
"loading"
)
{
// 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/partialLoadReady.php
0 → 100644
View file @
0f553ed0
<?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/testinit.js
View file @
0f553ed0
...
@@ -223,7 +223,7 @@ function url( value ) {
...
@@ -223,7 +223,7 @@ function url( value ) {
},
0
);
},
0
);
};
};
iframe
=
jQuery
(
"<div/>"
).
append
(
iframe
=
jQuery
(
"<div/>"
).
append
(
jQuery
(
"<iframe/>"
).
attr
(
"src"
,
url
(
"./data/"
+
fileName
+
".html"
)
)
jQuery
(
"<iframe/>"
).
attr
(
"src"
,
url
(
"./data/"
+
fileName
)
)
).
appendTo
(
"body"
);
).
appendTo
(
"body"
);
});
});
}
}
...
...
test/unit/event.js
View file @
0f553ed0
...
@@ -2888,28 +2888,33 @@ test("fixHooks extensions", function() {
...
@@ -2888,28 +2888,33 @@ test("fixHooks extensions", function() {
// which breaks order of execution on async loaded files
// which breaks order of execution on async loaded files
// also need PHP to make the incepted IFRAME hang
// also need PHP to make the incepted IFRAME hang
if
(
hasPHP
)
{
if
(
hasPHP
)
{
testIframeWithCallback
(
"jQuery.ready promise"
,
"event/promiseReady"
,
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"
);
});
});
// oldIE needs all subresources to be loaded before it can gaurantee the document is truly ready to be interacted with
testIframeWithCallback
(
"jQuery.ready synchronous load with long loading subresources"
,
"event/syncReady.html"
,
function
(
isOk
)
{
if
(
document
.
addEventListener
)
{
expect
(
1
);
testIframeWithCallback
(
"jQuery.ready synchronous load with long loading iframe"
,
"event/syncReadyLongLoad"
,
function
(
isOk
)
{
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
);
expect
(
1
);
ok
(
isOk
,
"jQuery loaded synchronously fires ready before all sub-resources are loaded"
);
ok
(
isOk
,
"jQuery loaded synchronously fires ready before all sub-resources are loaded"
);
});
});
testIframeWithCallback
(
"jQuery.ready asynchronous load with long loading iframe"
,
"event/asyncReady"
,
function
(
isOk
)
{
testIframeWithCallback
(
"jQuery.ready asynchronous load with long loading iframe"
,
"event/asyncReady
.html
"
,
function
(
isOk
)
{
expect
(
1
);
expect
(
1
);
ok
(
isOk
,
"jQuery loaded asynchronously fires ready before all sub-resources are loaded"
);
ok
(
isOk
,
"jQuery loaded asynchronously fires ready before all sub-resources are loaded"
);
});
});
}
}
testIframeWithCallback
(
"jQuery.ready synchronous load with long loading subresources"
,
"event/syncReady"
,
function
(
isOk
)
{
expect
(
1
);
ok
(
isOk
,
"jQuery loaded synchronously fires ready when the DOM can truly be interacted with"
);
});
}
}
(
function
(){
(
function
(){
...
...
test/unit/support.js
View file @
0f553ed0
...
@@ -7,7 +7,7 @@ test("boxModel", function() {
...
@@ -7,7 +7,7 @@ test("boxModel", function() {
});
});
if
(
jQuery
.
css
)
{
if
(
jQuery
.
css
)
{
testIframeWithCallback
(
"body background is not lost if set prior to loading jQuery (#9238)"
,
"support/bodyBackground"
,
function
(
color
,
support
)
{
testIframeWithCallback
(
"body background is not lost if set prior to loading jQuery (#9238)"
,
"support/bodyBackground
.html
"
,
function
(
color
,
support
)
{
expect
(
2
);
expect
(
2
);
var
i
,
var
i
,
passed
=
true
,
passed
=
true
,
...
@@ -33,7 +33,7 @@ if ( jQuery.css ) {
...
@@ -33,7 +33,7 @@ if ( jQuery.css ) {
});
});
}
}
testIframeWithCallback
(
"A background on the testElement does not cause IE8 to crash (#9823)"
,
"support/testElementCrash"
,
function
()
{
testIframeWithCallback
(
"A background on the testElement does not cause IE8 to crash (#9823)"
,
"support/testElementCrash
.html
"
,
function
()
{
expect
(
1
);
expect
(
1
);
ok
(
true
,
"IE8 does not crash"
);
ok
(
true
,
"IE8 does not crash"
);
});
});
...
...
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