John, it is not what I though. The script is not executed at all so I guess it is inside the html method.
If you want I can change ready but it is present in different parts, as prototype, as public static, as setup, but reading again the logic it seems to be OK. I personally do not like it because in my opinion bindReady should be called just once in any case and I would split the logic.
What I mean, is that this line in event.js 399 does not make sense:
// Make sure the ready event is setup ...
bindReady could be an anonymous function.
<br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">(function(){ // bindReady
if ( document.readyState === "complete" )
return jQuery.ready();
var c, fn;
if ( document.addEventListener ) {
document.addEventListener( "DOMContentLoaded", c = function() {
document.removeEventListener( "DOMContentLoaded", c, false );
jQuery.ready();
}, false );
} else if ( document.attachEvent ) {
document.attachEvent("onreadystatechange", c = function() {
if ( document.readyState === "complete" ) {
document.detachEvent( "onreadystatechange", c );
jQuery.ready();
}
});
if ( document.documentElement.doScroll && window === window.top ) (fn = function() {
if ( jQuery.isReady )
return;
try {
document.documentElement.doScroll("left");
} catch( error ) {
setTimeout( fn, 0 );
return;
}
jQuery.ready();
})();
}
jQuery.event.add( window, "load", jQuery.ready );
})();</span>
removing dependencies from external scope and variables a la boundReady
So everything is delegated to jQuery.ready callback which could be part of this extend
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">jQuery.extend({</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> isReady: false,</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> readyList: [],</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ready: function() {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if(jQuery.isReady) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> while(jQuery.readyList.length)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> jQuery.readyList.shift().call(document, jQuery);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> } else {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> jQuery.isReady = true;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> jQuery.ready(); // as a goto:if and come back</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> jQuery( document ).triggerHandler( "ready" );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">});</span>
making everything more simple ( and an empty array has never been a memory problem )
at this point the only thing jQuery.fn.ready should do:
<span style="font-family: courier new,monospace;">ready: function( fn ) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> jQuery.isReady ? fn.call( document, jQuery ) : jQuery.readyList.push( fn );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> return this;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> },</span>
and nothing else. The only interference could be the global static isReady. If we would like to feel more safe about this we could simply use an internal isReady and copy its value for each ready call in order to avoid obtrusive code ( but it is a truly silly hack if someone does it ).
As summary, with internal isReady variable, and already tested, tell me if you want a patch ...
<span style="font-family: courier new,monospace;">jQuery.extend({</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> isReady: false,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> readyList: [],</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> ready: function() {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> if(jQuery.isReady = isReady) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> while(jQuery.readyList.length)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> jQuery.readyList.shift().call(document, jQuery);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> } else {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> isReady = true;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> jQuery.ready(); // as a goto:if and come back</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> jQuery( document ).triggerHandler( "ready" );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">});</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">var isReady = (function(){ // bindReady</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if ( document.readyState === "complete" )</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> return jQuery.ready();</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> var c, fn;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> if ( document.addEventListener ) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> document.addEventListener( "DOMContentLoaded", c = function() {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> document.removeEventListener( "DOMContentLoaded", c, false );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> jQuery.ready();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }, false );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> } else if ( document.attachEvent ) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> document.attachEvent("onreadystatechange", c = function() {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if ( document.readyState === "complete" ) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> document.detachEvent( "onreadystatechange", c );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> jQuery.ready();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> });</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> if ( document.documentElement.doScroll && window === window.top ) (fn = function() {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if ( jQuery.isReady )</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> return;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> try {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> document.documentElement.doScroll("left");</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> } catch( error ) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> setTimeout( fn, 0 );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> return;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> jQuery.ready();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> })();</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> jQuery.event.add( window, "load", jQuery.ready );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> return false;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">})();</span>
<br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">ready: function( fn ) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> isReady ? fn.call( document, jQuery ) : jQuery.readyList.push( fn );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> return this;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> },</span>
removing setup:bindReady from the other object.