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
f3c776dc
Commit
f3c776dc
authored
Jan 22, 2013
by
Oleg
Committed by
Dave Methvin
Feb 04, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #13356. Clean up after load/ready handlers. Close gh-1152.
parent
8226666b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
13 deletions
+24
-13
core.js
src/core.js
+24
-13
No files found.
src/core.js
View file @
f3c776dc
...
...
@@ -74,17 +74,25 @@ var
return
letter
.
toUpperCase
();
},
// The ready event handler and self cleanup method
DOMContentLoaded
=
function
()
{
if
(
document
.
addEventListener
)
{
document
.
removeEventListener
(
"DOMContentLoaded"
,
DOMContentLoaded
,
false
);
jQuery
.
ready
();
}
else
if
(
document
.
readyState
===
"complete"
)
{
// we're here because readyState === "complete" in oldIE
// which is good enough for us to call the dom ready!
document
.
detachEvent
(
"onreadystatechange"
,
DOMContentLoaded
);
// The ready event handler
completed
=
function
(
event
)
{
// readyState === "complete" is good enough for us to call the dom ready in oldIE
if
(
document
.
addEventListener
||
event
.
type
===
"load"
||
document
.
readyState
===
"complete"
)
{
detach
();
jQuery
.
ready
();
}
},
// Clean-up method for dom ready events
detach
=
function
()
{
if
(
document
.
addEventListener
)
{
document
.
removeEventListener
(
"DOMContentLoaded"
,
completed
,
false
);
window
.
removeEventListener
(
"load"
,
completed
,
false
);
}
else
{
document
.
detachEvent
(
"onreadystatechange"
,
completed
);
window
.
detachEvent
(
"onload"
,
completed
);
}
};
jQuery
.
fn
=
jQuery
.
prototype
=
{
...
...
@@ -869,18 +877,18 @@ jQuery.ready.promise = function( obj ) {
// Standards-based browsers support DOMContentLoaded
}
else
if
(
document
.
addEventListener
)
{
// Use the handy event callback
document
.
addEventListener
(
"DOMContentLoaded"
,
DOMContentLoad
ed
,
false
);
document
.
addEventListener
(
"DOMContentLoaded"
,
complet
ed
,
false
);
// A fallback to window.onload, that will always work
window
.
addEventListener
(
"load"
,
jQuery
.
ready
,
false
);
window
.
addEventListener
(
"load"
,
completed
,
false
);
// If IE event model is used
}
else
{
// Ensure firing before onload, maybe late but safe also for iframes
document
.
attachEvent
(
"onreadystatechange"
,
DOMContentLoad
ed
);
document
.
attachEvent
(
"onreadystatechange"
,
complet
ed
);
// A fallback to window.onload, that will always work
window
.
attachEvent
(
"onload"
,
jQuery
.
ready
);
window
.
attachEvent
(
"onload"
,
completed
);
// If IE and not a frame
// continually check to see if the document is ready
...
...
@@ -902,6 +910,9 @@ jQuery.ready.promise = function( obj ) {
return
setTimeout
(
doScrollCheck
,
50
);
}
// detach all dom ready events
detach
();
// and execute any waiting functions
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