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
4c1e12e8
Commit
4c1e12e8
authored
Dec 19, 2008
by
John Resig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplifying the DOM ready code, no longer attempting to handle stylesheet loading. Closes #2614.
parent
ba4453de
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
40 deletions
+14
-40
event.js
src/event.js
+14
-40
No files found.
src/event.js
View file @
4c1e12e8
...
@@ -521,27 +521,30 @@ function bindReady(){
...
@@ -521,27 +521,30 @@ function bindReady(){
if
(
readyBound
)
return
;
if
(
readyBound
)
return
;
readyBound
=
true
;
readyBound
=
true
;
// Mozilla, Opera
(see further below for it)
and webkit nightlies currently support this event
// Mozilla, Opera and webkit nightlies currently support this event
if
(
document
.
addEventListener
&&
!
jQuery
.
browser
.
opera
)
if
(
document
.
addEventListener
)
{
// Use the handy event callback
// Use the handy event callback
document
.
addEventListener
(
"DOMContentLoaded"
,
jQuery
.
ready
,
false
);
document
.
addEventListener
(
"DOMContentLoaded"
,
function
(){
document
.
removeEventListener
(
"DOMContentLoaded"
,
arguments
.
callee
,
false
);
jQuery
.
ready
();
},
false
);
// If IE event model is used
// If IE event model is used
if
(
document
.
attachEvent
)
}
else
if
(
document
.
attachEvent
)
{
// ensure firing before onload,
// ensure firing before onload,
// maybe late but safe also for iframes
// maybe late but safe also for iframes
document
.
attachEvent
(
"onreadystatechange"
,
function
(
e
)
{
document
.
attachEvent
(
"onreadystatechange"
,
function
(
)
{
if
(
document
.
readyState
==
"complete"
)
{
if
(
document
.
readyState
==
=
"complete"
)
{
document
.
detachEvent
(
"onreadystatechange"
,
arguments
.
callee
);
document
.
detachEvent
(
"onreadystatechange"
,
arguments
.
callee
);
jQuery
.
ready
();
jQuery
.
ready
();
}
}
});
});
// If IE and not an iframe
// If IE and not an iframe
if
(
document
.
documentElement
.
doScroll
&&
!
window
.
frameElement
)
// continually check to see if the document is ready
// continually check to see if the document is ready
(
function
(){
if
(
document
.
documentElement
.
doScroll
&&
!
window
.
frameElement
)
(
function
(){
if
(
jQuery
.
isReady
)
return
;
if
(
jQuery
.
isReady
)
return
;
try
{
try
{
// If IE is used, use the trick by Diego Perini
// If IE is used, use the trick by Diego Perini
// http://javascript.nwbox.com/IEContentLoaded/
// http://javascript.nwbox.com/IEContentLoaded/
...
@@ -550,36 +553,7 @@ function bindReady(){
...
@@ -550,36 +553,7 @@ function bindReady(){
setTimeout
(
arguments
.
callee
,
0
);
setTimeout
(
arguments
.
callee
,
0
);
return
;
return
;
}
}
// and execute any waiting functions
jQuery
.
ready
();
})();
if
(
jQuery
.
browser
.
opera
)
document
.
addEventListener
(
"DOMContentLoaded"
,
function
()
{
if
(
jQuery
.
isReady
)
return
;
for
(
var
i
=
0
;
i
<
document
.
styleSheets
.
length
;
i
++
)
if
(
document
.
styleSheets
[
i
].
disabled
)
{
setTimeout
(
arguments
.
callee
,
0
);
return
;
}
// and execute any waiting functions
jQuery
.
ready
();
},
false
);
if
(
jQuery
.
browser
.
safari
)
{
var
numStyles
;
(
function
(){
if
(
jQuery
.
isReady
)
return
;
if
(
document
.
readyState
!=
"loaded"
&&
document
.
readyState
!=
"complete"
)
{
setTimeout
(
arguments
.
callee
,
0
);
return
;
}
if
(
numStyles
===
undefined
)
numStyles
=
jQuery
(
"style, link[rel=stylesheet]"
).
length
;
if
(
document
.
styleSheets
.
length
!=
numStyles
)
{
setTimeout
(
arguments
.
callee
,
0
);
return
;
}
// and execute any waiting functions
// and execute any waiting functions
jQuery
.
ready
();
jQuery
.
ready
();
})();
})();
...
...
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