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.

(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 );
})();

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

jQuery.extend({
    isReady: false,
    readyList: [],
    ready: function() {
        if(jQuery.isReady) {
            while(jQuery.readyList.length)
                jQuery.readyList.shift().call(document, jQuery);
        } else {
            jQuery.isReady = true;
            jQuery.ready(); // as a goto:if and come back
            jQuery( document ).triggerHandler( "ready" );
        }
    }
});

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:

ready: function( fn ) {
        jQuery.isReady ? fn.call( document, jQuery ) :
jQuery.readyList.push( fn );
        return this;
    },

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 ...


jQuery.extend({
    isReady: false,
    readyList: [],
    ready: function() {
        if(jQuery.isReady = isReady) {
            while(jQuery.readyList.length)
                jQuery.readyList.shift().call(document, jQuery);
        } else {
            isReady = true;
            jQuery.ready(); // as a goto:if and come back
            jQuery( document ).triggerHandler( "ready" );
        }
    }
});

var isReady = (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 );
    return false;
})();

ready: function( fn ) {
        isReady ? fn.call( document, jQuery ) : jQuery.readyList.push( fn );
        return this;
    },


removing setup:bindReady from the other object.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-dev@googlegroups.com
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to