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
714b8ffd
Commit
714b8ffd
authored
May 04, 2012
by
Mike Sherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reduce complexity of ready further, and try manipulating DOM to make sure we're really ready
parent
f925c7a1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
7 deletions
+7
-7
core.js
src/core.js
+5
-7
asyncReady.html
test/data/event/asyncReady.html
+1
-0
syncReady.html
test/data/event/syncReady.html
+1
-0
No files found.
src/core.js
View file @
714b8ffd
...
@@ -59,18 +59,16 @@ var jQuery = function( selector, context ) {
...
@@ -59,18 +59,16 @@ var jQuery = function( selector, context ) {
// The deferred used on DOM ready
// The deferred used on DOM ready
readyList
,
readyList
,
// The ready event handler
// The ready event handler and self cleanup method
// Cleanup function for the document ready method
DOMContentLoaded
=
function
()
{
DOMContentLoaded
=
function
()
{
if
(
document
.
addEventListener
)
{
if
(
document
.
addEventListener
)
{
document
.
removeEventListener
(
"DOMContentLoaded"
,
DOMContentLoaded
,
false
);
document
.
removeEventListener
(
"DOMContentLoaded"
,
DOMContentLoaded
,
false
);
jQuery
.
ready
();
}
else
{
}
else
if
(
document
.
readyState
!==
"loading"
)
{
// we're here because readyState !== "loading" in oldIE
// if document.addEventListener isn't present, we assume detachEvent is!
// which is good enough for us to call the dom ready!
// Make sure body exists by checking readystate, at least, in case IE gets a little overzealous (ticket #5443).
document
.
detachEvent
(
"onreadystatechange"
,
DOMContentLoaded
);
document
.
detachEvent
(
"onreadystatechange"
,
DOMContentLoaded
);
jQuery
.
ready
();
}
}
jQuery
.
ready
();
},
},
// Save a reference to some core methods
// Save a reference to some core methods
...
...
test/data/event/asyncReady.html
View file @
714b8ffd
...
@@ -14,6 +14,7 @@ if ( document.attachEvent ) {
...
@@ -14,6 +14,7 @@ if ( document.attachEvent ) {
el
.
type
=
"text/javascript"
;
el
.
type
=
"text/javascript"
;
el
.
onload
=
function
()
{
el
.
onload
=
function
()
{
jQuery
(
document
).
ready
(
function
()
{
jQuery
(
document
).
ready
(
function
()
{
jQuery
(
"body"
).
append
(
"<div>modifying DOM</div>"
);
window
.
parent
.
iframeCallback
(
true
);
window
.
parent
.
iframeCallback
(
true
);
});
});
}
}
...
...
test/data/event/syncReady.html
View file @
714b8ffd
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
<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
(
true
);
window
.
parent
.
iframeCallback
(
true
);
});
});
</script>
</script>
...
...
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