Skip to content

Commit 8491f22

Browse files
johncrenshawjohncrenshaw
authored andcommitted
When adding robust $.include and ajax functionality I needed to be able to delays execution of ready(fn) functions 1) while requested includes were still loading and 2) while new ajax content (and related includes) were still loading. This required extending ready() to add extra ready conditions, but 1.4.2 had some issues that prevented this from being possible.
I made minor fixes in 4 places that will have no impact on working code, but will allow this type of improvement in the future. Comments marked MYEDIT explain exactly what and why.
1 parent 0bbbe5f commit 8491f22

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

jquery-1.4.2.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,11 @@ jQuery.extend({
371371

372372
// Is the DOM ready to be used? Set to true once it occurs.
373373
isReady: false,
374+
375+
// MYEDIT: stub so that ready can be extended without having
376+
// to be rebound to load events (load events point here rather
377+
// than directly at ready())
378+
_onReady: function() {jQuery.ready();},
374379

375380
// Handle when the DOM is ready
376381
ready: function() {
@@ -393,7 +398,7 @@ jQuery.extend({
393398
}
394399

395400
// Reset the list of functions
396-
readyList = null;
401+
readyList = []; // MYEDIT: setting to "null" prevents anything from being added to the list again. This becomes a problem if you try to implement ajax includes.
397402
}
398403

399404
// Trigger any bound ready events
@@ -422,7 +427,7 @@ jQuery.extend({
422427
document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
423428

424429
// A fallback to window.onload, that will always work
425-
window.addEventListener( "load", jQuery.ready, false );
430+
window.addEventListener( "load", jQuery._onReady, false ); // MYEDIT: use stub so ready() can be extended easily
426431

427432
// If IE event model is used
428433
} else if ( document.attachEvent ) {
@@ -431,7 +436,7 @@ jQuery.extend({
431436
document.attachEvent("onreadystatechange", DOMContentLoaded);
432437

433438
// A fallback to window.onload, that will always work
434-
window.attachEvent( "onload", jQuery.ready );
439+
window.attachEvent( "onload", jQuery._onReady ); // MYEDIT: use stub so ready() can be extended easily
435440

436441
// If IE and not a frame
437442
// continually check to see if the document is ready

0 commit comments

Comments
 (0)