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
f5fd4125
Commit
f5fd4125
authored
Jul 06, 2012
by
Mike Sherov
Committed by
Dave Methvin
Jul 06, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #12018, readyState "interactive" in oldIE lies! Closes gh-848.
parent
aaf134bb
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
77 additions
and
34 deletions
+77
-34
core.js
src/core.js
+5
-4
asyncReady.html
test/data/event/asyncReady.html
+17
-18
longLoadScript.php
test/data/event/longLoadScript.php
+4
-0
promiseReady.html
test/data/event/promiseReady.html
+1
-1
syncReady.html
test/data/event/syncReady.html
+9
-4
syncReadyLongLoad.html
test/data/event/syncReadyLongLoad.html
+26
-0
event.js
test/unit/event.js
+15
-7
No files found.
src/core.js
View file @
f5fd4125
...
@@ -63,12 +63,13 @@ var
...
@@ -63,12 +63,13 @@ var
DOMContentLoaded
=
function
()
{
DOMContentLoaded
=
function
()
{
if
(
document
.
addEventListener
)
{
if
(
document
.
addEventListener
)
{
document
.
removeEventListener
(
"DOMContentLoaded"
,
DOMContentLoaded
,
false
);
document
.
removeEventListener
(
"DOMContentLoaded"
,
DOMContentLoaded
,
false
);
}
else
{
jQuery
.
ready
();
// we're here because readyState !== "loading" in oldIE
}
else
if
(
document
.
readyState
===
"complete"
)
{
// we're here because readyState === "complete" in oldIE
// which is good enough for us to call the dom ready!
// which is good enough for us to call the dom ready!
document
.
detachEvent
(
"onreadystatechange"
,
DOMContentLoaded
);
document
.
detachEvent
(
"onreadystatechange"
,
DOMContentLoaded
);
jQuery
.
ready
();
}
}
jQuery
.
ready
();
},
},
// [[Class]] -> type pairs
// [[Class]] -> type pairs
...
@@ -818,7 +819,7 @@ jQuery.ready.promise = function( obj ) {
...
@@ -818,7 +819,7 @@ jQuery.ready.promise = function( obj ) {
// 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.
if
(
document
.
readyState
!==
"loading"
)
{
if
(
document
.
readyState
===
"complete"
||
(
document
.
readyState
!==
"loading"
&&
document
.
addEventListener
)
)
{
// 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
View file @
f5fd4125
...
@@ -4,27 +4,26 @@
...
@@ -4,27 +4,26 @@
<meta
http-equiv=
"content-type"
content=
"text/html; charset=utf-8"
>
<meta
http-equiv=
"content-type"
content=
"text/html; charset=utf-8"
>
<title>
Test case for jQuery ticket #10067
</title>
<title>
Test case for jQuery ticket #10067
</title>
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
if
(
document
.
attachEvent
)
{
setTimeout
(
function
()
{
// browsers that use the non-standard event API will load the iframe
el
=
document
.
createElement
(
"script"
);
// before jQuery, so there's no way to fire ready before the iframe loads
el
.
type
=
"text/javascript"
;
window
.
parent
.
iframeCallback
(
true
);
el
.
onload
=
function
()
{
}
else
{
jQuery
(
document
).
ready
(
function
()
{
setTimeout
(
function
()
{
window
.
parent
.
iframeCallback
(
jQuery
(
'#container'
).
length
===
1
);
el
=
document
.
createElement
(
"script"
);
});
el
.
type
=
"text/javascript"
;
}
el
.
onload
=
function
()
{
document
.
getElementsByTagName
(
"head"
)[
0
].
appendChild
(
el
);
jQuery
(
document
).
ready
(
function
()
{
el
.
src
=
"../../../dist/jquery.js"
;
jQuery
(
"body"
).
append
(
"<div>modifying DOM</div>"
);
},
1000
);
window
.
parent
.
iframeCallback
(
true
);
});
}
document
.
getElementsByTagName
(
"head"
)[
0
].
appendChild
(
el
);
el
.
src
=
"../../../dist/jquery.js"
;
},
1000
);
}
</script>
</script>
</head>
</head>
<body>
<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 -->
<!-- long loading iframe -->
<iframe
src=
"longLoad.php?sleep=15&return=false"
style=
"width: 1px; height: 1px"
></iframe>
<iframe
src=
"longLoad.php?sleep=15&return=false"
style=
"width: 1px; height: 1px"
></iframe>
</body>
</body>
...
...
test/data/event/longLoadScript.php
0 → 100644
View file @
f5fd4125
<?php
sleep
((
int
)
$_GET
[
'sleep'
]);
header
(
'Content-type: text/javascript'
);
?>
\ No newline at end of file
test/data/event/promiseReady.html
View file @
f5fd4125
...
@@ -12,6 +12,6 @@ jQuery.when( jQuery.ready ).done(function() {
...
@@ -12,6 +12,6 @@ jQuery.when( jQuery.ready ).done(function() {
</script>
</script>
</head>
</head>
<body>
<body>
<!--
long loading iframe
-->
<!--
empty body
-->
</body>
</body>
</html>
</html>
test/data/event/syncReady.html
View file @
f5fd4125
...
@@ -6,13 +6,18 @@
...
@@ -6,13 +6,18 @@
<script
type=
"text/javascript"
src=
"../../../dist/jquery.js"
></script>
<script
type=
"text/javascript"
src=
"../../../dist/jquery.js"
></script>
</head>
</head>
<body>
<body>
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
jQuery
(
document
).
ready
(
function
()
{
jQuery
(
document
).
ready
(
function
()
{
jQuery
(
"body"
).
append
(
"<div>modifying DOM</div>"
);
window
.
parent
.
iframeCallback
(
jQuery
(
'#container'
).
length
===
1
);
window
.
parent
.
iframeCallback
(
true
);
});
});
</script>
</script>
<!-- long loading iframe -->
<iframe
src=
"longLoad.php?sleep=10&return=false"
style=
"width: 1px; height: 1px"
></iframe>
<!-- 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>
</body>
</body>
</html>
</html>
test/data/event/syncReadyLongLoad.html
0 → 100644
View file @
f5fd4125
<!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 @
f5fd4125
...
@@ -2345,7 +2345,7 @@ test("jQuery.off using dispatched jQuery.Event", function() {
...
@@ -2345,7 +2345,7 @@ test("jQuery.off using dispatched jQuery.Event", function() {
test
(
"delegated event with delegateTarget-relative selector (#)"
,
function
()
{
test
(
"delegated event with delegateTarget-relative selector (#)"
,
function
()
{
expect
(
1
);
expect
(
1
);
var
markup
=
jQuery
(
'<ul><li><ul id="u1"><li id="f1"></li></ul></li>'
).
appendTo
(
"body"
);
var
markup
=
jQuery
(
'<ul><li><ul id="u1"><li id="f1"></li></ul></li>'
).
appendTo
(
"body"
);
markup
markup
.
find
(
"#u1"
)
.
find
(
"#u1"
)
.
on
(
"click"
,
"li:first"
,
function
()
{
.
on
(
"click"
,
"li:first"
,
function
()
{
...
@@ -2884,14 +2884,22 @@ if ( hasPHP ) {
...
@@ -2884,14 +2884,22 @@ if ( hasPHP ) {
ok
(
isOk
,
"$.when( $.ready ) works"
);
ok
(
isOk
,
"$.when( $.ready ) works"
);
});
});
testIframeWithCallback
(
"jQuery.ready synchronous load with long loading iframe"
,
"event/syncReady"
,
function
(
isOk
)
{
// oldIE needs all subresources to be loaded before it can gaurantee the document is truly ready to be interacted with
expect
(
1
);
if
(
document
.
addEventListener
)
{
ok
(
isOk
,
"jQuery loaded synchronously fires ready before all sub-resources are loaded"
);
testIframeWithCallback
(
"jQuery.ready synchronous load with long loading iframe"
,
"event/syncReadyLongLoad"
,
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"
,
function
(
isOk
)
{
expect
(
1
);
ok
(
isOk
,
"jQuery loaded asynchronously fires ready before all sub-resources are loaded"
);
});
}
testIframeWithCallback
(
"jQuery.ready
asynchronous load with long loading iframe"
,
"event/a
syncReady"
,
function
(
isOk
)
{
testIframeWithCallback
(
"jQuery.ready
synchronous load with long loading subresources"
,
"event/
syncReady"
,
function
(
isOk
)
{
expect
(
1
);
expect
(
1
);
ok
(
isOk
,
"jQuery loaded
asynchronously fires ready before all sub-resources are loaded
"
);
ok
(
isOk
,
"jQuery loaded
synchronously fires ready when the DOM can truly be interacted with
"
);
});
});
}
}
...
...
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