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
f925c7a1
Commit
f925c7a1
authored
May 04, 2012
by
Mike Sherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove jQuery.quickReady, save bytes, style nits in tests
parent
bab6f535
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
70 deletions
+50
-70
core.js
src/core.js
+13
-28
asyncQuickReadyFalse.html
test/data/event/asyncQuickReadyFalse.html
+0
-32
asyncReady.html
test/data/event/asyncReady.html
+30
-0
syncReady.html
test/data/event/syncReady.html
+2
-2
event.js
test/unit/event.js
+5
-8
No files found.
src/core.js
View file @
f925c7a1
...
@@ -60,7 +60,18 @@ var jQuery = function( selector, context ) {
...
@@ -60,7 +60,18 @@ var jQuery = function( selector, context ) {
readyList
,
readyList
,
// The ready event handler
// The ready event handler
DOMContentLoaded
,
// Cleanup function for the document ready method
DOMContentLoaded
=
function
()
{
if
(
document
.
addEventListener
)
{
document
.
removeEventListener
(
"DOMContentLoaded"
,
DOMContentLoaded
,
false
);
jQuery
.
ready
();
}
else
if
(
document
.
readyState
!==
"loading"
)
{
// if document.addEventListener isn't present, we assume detachEvent is!
// Make sure body exists by checking readystate, at least, in case IE gets a little overzealous (ticket #5443).
document
.
detachEvent
(
"onreadystatechange"
,
DOMContentLoaded
);
jQuery
.
ready
();
}
},
// Save a reference to some core methods
// Save a reference to some core methods
toString
=
Object
.
prototype
.
toString
,
toString
=
Object
.
prototype
.
toString
,
...
@@ -375,9 +386,6 @@ jQuery.extend({
...
@@ -375,9 +386,6 @@ jQuery.extend({
// the ready event fires. See #6781
// the ready event fires. See #6781
readyWait
:
1
,
readyWait
:
1
,
// should we fire ready on readyState "interactive" ?
quickReady
:
true
,
// Hold (or release) the ready event
// Hold (or release) the ready event
holdReady
:
function
(
hold
)
{
holdReady
:
function
(
hold
)
{
if
(
hold
)
{
if
(
hold
)
{
...
@@ -389,11 +397,6 @@ jQuery.extend({
...
@@ -389,11 +397,6 @@ jQuery.extend({
// Handle when the DOM is ready
// Handle when the DOM is ready
ready
:
function
(
wait
)
{
ready
:
function
(
wait
)
{
// user wasn't necessarily given the chance to set jQuery.quickReady before bindReady
// so we check here for quickReady instead
if
(
!
jQuery
.
quickReady
&&
document
.
readyState
===
"interactive"
)
{
return
;
}
// Either a released hold or an DOMready/load event and not yet ready
// Either a released hold or an DOMready/load event and not yet ready
if
(
(
wait
===
true
&&
!--
jQuery
.
readyWait
)
||
(
wait
!==
true
&&
!
jQuery
.
isReady
)
)
{
if
(
(
wait
===
true
&&
!--
jQuery
.
readyWait
)
||
(
wait
!==
true
&&
!
jQuery
.
isReady
)
)
{
...
@@ -431,7 +434,7 @@ jQuery.extend({
...
@@ -431,7 +434,7 @@ jQuery.extend({
// browser event has already occurred.
// browser event has already occurred.
if
(
document
.
readyState
!==
"loading"
)
{
if
(
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
);
return
setTimeout
(
jQuery
.
ready
,
1
);
}
}
// Mozilla, Opera and webkit nightlies currently support this event
// Mozilla, Opera and webkit nightlies currently support this event
...
@@ -921,24 +924,6 @@ if ( rnotwhite.test( "\xA0" ) ) {
...
@@ -921,24 +924,6 @@ if ( rnotwhite.test( "\xA0" ) ) {
// All jQuery objects should point back to these
// All jQuery objects should point back to these
rootjQuery
=
jQuery
(
document
);
rootjQuery
=
jQuery
(
document
);
// Cleanup functions for the document ready method
if
(
document
.
addEventListener
)
{
DOMContentLoaded
=
function
()
{
jQuery
.
quickReady
=
true
;
document
.
removeEventListener
(
"DOMContentLoaded"
,
DOMContentLoaded
,
false
);
jQuery
.
ready
();
};
}
else
if
(
document
.
attachEvent
)
{
DOMContentLoaded
=
function
()
{
// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
if
(
document
.
readyState
===
"complete"
||
(
jQuery
.
quickReady
&&
document
.
readyState
===
"interactive"
)
)
{
document
.
detachEvent
(
"onreadystatechange"
,
DOMContentLoaded
);
jQuery
.
ready
();
}
};
}
// The DOM ready check for Internet Explorer
// The DOM ready check for Internet Explorer
function
doScrollCheck
()
{
function
doScrollCheck
()
{
if
(
jQuery
.
isReady
)
{
if
(
jQuery
.
isReady
)
{
...
...
test/data/event/asyncQuickReadyFalse.html
deleted
100644 → 0
View file @
bab6f535
<!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"
>
// ready should fire callback after the iframe fires the callback
setTimeout
(
function
()
{
el
=
document
.
createElement
(
'script'
);
el
.
type
=
'text/javascript'
;
el
.
onload
=
function
()
{
jQuery
.
quickReady
=
false
;
jQuery
(
document
).
ready
(
function
()
{
// unfortunately, Opera 11.6 and lower has a bug where
// document.readyState is "complete" before all subresources
// are loaded, so we need this check here for tests to pass
if
(
document
.
readyState
!==
"complete"
)
{
window
.
parent
.
iframeCallback
(
false
);
}
});
}
document
.
getElementsByTagName
(
'head'
)[
0
].
appendChild
(
el
);
el
.
src
=
"../include_js.php"
;
},
1000
);
</script>
</head>
<body>
<!-- long loading iframe -->
<iframe
src=
"longLoad.php?sleep=3&return=true"
style=
"width: 1px; height: 1px"
></iframe>
</body>
</html>
\ No newline at end of file
test/data/event/async
QuickReadyTrue
.html
→
test/data/event/async
Ready
.html
View file @
f925c7a1
...
@@ -4,27 +4,27 @@
...
@@ -4,27 +4,27 @@
<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"
>
// browsers that implement the non-standard event API will load the iframe
if
(
document
.
attachEvent
)
{
// before loading up jQuery, so quickReady has no effect her
e
// browsers that use the non-standard event API will load the ifram
e
if
(
document
.
attachEvent
){
// before jQuery, so there's no way to fire ready before the iframe loads
window
.
parent
.
iframeCallback
(
true
);
window
.
parent
.
iframeCallback
(
true
);
}
else
{
}
else
{
setTimeout
(
function
()
{
setTimeout
(
function
()
{
el
=
document
.
createElement
(
'script'
);
el
=
document
.
createElement
(
"script"
);
el
.
type
=
'text/javascript'
;
el
.
type
=
"text/javascript"
;
el
.
onload
=
function
()
{
el
.
onload
=
function
()
{
jQuery
(
document
).
ready
(
function
()
{
jQuery
(
document
).
ready
(
function
()
{
window
.
parent
.
iframeCallback
(
true
);
window
.
parent
.
iframeCallback
(
true
);
});
});
}
}
document
.
getElementsByTagName
(
'head'
)[
0
].
appendChild
(
el
);
document
.
getElementsByTagName
(
"head"
)[
0
].
appendChild
(
el
);
el
.
src
=
"../include_js.php"
;
el
.
src
=
"../include_js.php"
;
},
1000
);
},
1000
);
}
}
</script>
</script>
</head>
</head>
<body>
<body>
<!-- long loading iframe -->
<!-- long loading iframe -->
<iframe
src=
"longLoad.php?sleep=
30
&return=false"
style=
"width: 1px; height: 1px"
></iframe>
<iframe
src=
"longLoad.php?sleep=
15
&return=false"
style=
"width: 1px; height: 1px"
></iframe>
</body>
</body>
</html>
</html>
\ No newline at end of file
test/data/event/syncReady.html
View file @
f925c7a1
...
@@ -7,8 +7,8 @@
...
@@ -7,8 +7,8 @@
</head>
</head>
<body>
<body>
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
jQuery
(
document
).
ready
(
function
()
{
jQuery
(
document
).
ready
(
function
()
{
window
.
parent
.
iframeCallback
(
true
);
window
.
parent
.
iframeCallback
(
true
);
});
});
</script>
</script>
<!-- long loading iframe -->
<!-- long loading iframe -->
...
...
test/unit/event.js
View file @
f925c7a1
...
@@ -2794,23 +2794,20 @@ test("fixHooks extensions", function() {
...
@@ -2794,23 +2794,20 @@ test("fixHooks extensions", function() {
jQuery
.
event
.
fixHooks
.
click
=
saved
;
jQuery
.
event
.
fixHooks
.
click
=
saved
;
});
});
testIframeWithCallback
(
"jQuery.ready sync load"
,
"event/syncReady"
,
function
(
isOk
)
{
expect
(
1
);
ok
(
isOk
,
"jQuery loaded synchronously fires ready before all sub-resources are loaded"
);
});
// async loaded tests expect jQuery to be loaded as a single file
// async loaded tests expect jQuery to be loaded as a single file
// if we're not doing PHP concat, then we fall back to document.write
// if we're not doing PHP concat, then we fall back to document.write
// 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
if
(
hasPHP
)
{
if
(
hasPHP
)
{
testIframeWithCallback
(
"jQuery.ready
async load with quickReady true"
,
"event/asyncQuickReadyTrue
"
,
function
(
isOk
)
{
testIframeWithCallback
(
"jQuery.ready
synchronous load with long loading iframe"
,
"event/syncReady
"
,
function
(
isOk
)
{
expect
(
1
);
expect
(
1
);
ok
(
isOk
,
"jQuery loaded
asynchronously with quickReady true
fires ready before all sub-resources are loaded"
);
ok
(
isOk
,
"jQuery loaded
synchronously
fires ready before all sub-resources are loaded"
);
});
});
testIframeWithCallback
(
"jQuery.ready async
load with quickReady false"
,
"event/asyncQuickReadyFalse
"
,
function
(
isOk
)
{
testIframeWithCallback
(
"jQuery.ready async
hronous load with long loading iframe"
,
"event/asyncReady
"
,
function
(
isOk
)
{
expect
(
1
);
expect
(
1
);
ok
(
isOk
,
"jQuery loaded asynchronously
with quickReady false fires ready after
all sub-resources are loaded"
);
ok
(
isOk
,
"jQuery loaded asynchronously
fires ready before
all sub-resources are loaded"
);
});
});
}
}
...
...
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