Bug Tracker

Ticket #1124: jquery-1.3.2+1124.patch

File jquery-1.3.2+1124.patch, 4.1 KB (added by ecmanaut, 3 years ago)

Patch towards jquery-1.3.2.js, implementing #1124

  • jquery-1.3.2.js.

    old new  
    29552955        }, 
    29562956 
    29572957        ready: function(fn) { 
     2958                var doc = this[0]; 
     2959 
    29582960                // Attach the listeners 
    2959                 bindReady(); 
     2961                bindReady(doc); 
    29602962 
    29612963                // If the DOM is already ready 
    2962                 if ( jQuery.isReady ) 
     2964                if ( this.data('isReady') ) 
    29632965                        // Execute the function immediately 
    2964                         fn.call( document, jQuery ); 
     2966                        fn.call( doc, jQuery ); 
    29652967 
    29662968                // Otherwise, remember the function for later 
    29672969                else 
    29682970                        // Add the function to the wait list 
    2969                         jQuery.readyList.push( fn ); 
     2971                        this.queue( 'readyList', fn ); 
    29702972 
    29712973                return this; 
    29722974        }, 
     
    30163018} 
    30173019 
    30183020jQuery.extend({ 
    3019         isReady: false, 
    3020         readyList: [], 
     3021        // NOTE: if official API, uncomment these two lines 
     3022        // isReady: false, 
    30213023        // Handle when the DOM is ready 
    3022         ready: function() { 
     3024        ready: function(doc) { 
     3025                var $doc = jQuery(doc); 
    30233026                // Make sure that the DOM is not already loaded 
    3024                 if ( !jQuery.isReady ) { 
     3027                if ( !$doc.data('isReady') ) { 
    30253028                        // Remember that the DOM is ready 
    3026                         jQuery.isReady = true; 
     3029                        // NOTE: if official API, uncomment these two lines 
     3030                        // if ( doc === document ) jQuery.isReady = true; 
     3031                        $doc.data( 'isReady', true ); 
    30273032 
    30283033                        // If there are functions bound, to execute 
    3029                         if ( jQuery.readyList ) { 
     3034                        if ( $doc.queue( 'readyList' ).length ) { 
    30303035                                // Execute all of them 
    3031                                 jQuery.each( jQuery.readyList, function(){ 
    3032                                         this.call( document, jQuery ); 
     3036                                jQuery.each($doc.queue('readyList'), function(){ 
     3037                                        this.call( doc, jQuery ); 
    30333038                                }); 
    30343039 
    30353040                                // Reset the list of functions 
    3036                                 jQuery.readyList = null; 
     3041                                $doc.queue('readyList', []); 
    30373042                        } 
    30383043 
    30393044                        // Trigger any bound ready events 
    3040                         jQuery(document).triggerHandler("ready"); 
     3045                        $doc.triggerHandler("ready"); 
    30413046                } 
    30423047        } 
    30433048}); 
    30443049 
    3045 var readyBound = false; 
     3050function bindReady(doc){ 
     3051        if (!doc) doc = document; 
     3052        var $doc = jQuery(doc); 
     3053        if ( $doc.data('readyBound') ) return; 
     3054        $doc.data('readyBound', true); 
    30463055 
    3047 function bindReady(){ 
    3048         if ( readyBound ) return; 
    3049         readyBound = true; 
     3056        var win = doc.defaultView || doc.parentWindow; 
    30503057 
    30513058        // Mozilla, Opera and webkit nightlies currently support this event 
    3052         if ( document.addEventListener ) { 
     3059        if ( doc.addEventListener ) { 
    30533060                // Use the handy event callback 
    3054                 document.addEventListener( "DOMContentLoaded", function(){ 
    3055                         document.removeEventListener( "DOMContentLoaded", arguments.callee, false ); 
    3056                         jQuery.ready(); 
     3061                doc.addEventListener( "DOMContentLoaded", function(){ 
     3062                        doc.removeEventListener( "DOMContentLoaded", arguments.callee, false ); 
     3063                        jQuery.ready(doc); 
    30573064                }, false ); 
    30583065 
    30593066        // If IE event model is used 
    3060         } else if ( document.attachEvent ) { 
     3067        } else if ( doc.attachEvent ) { 
    30613068                // ensure firing before onload, 
    30623069                // maybe late but safe also for iframes 
    3063                 document.attachEvent("onreadystatechange", function(){ 
    3064                         if ( document.readyState === "complete" ) { 
    3065                                 document.detachEvent( "onreadystatechange", arguments.callee ); 
    3066                                 jQuery.ready(); 
     3070                doc.attachEvent("onreadystatechange", function(){ 
     3071                        if ( doc.readyState === "complete" ) { 
     3072                                doc.detachEvent( "onreadystatechange", arguments.callee ); 
     3073                                jQuery.ready(doc); 
    30673074                        } 
    30683075                }); 
    30693076 
    30703077                // If IE and not an iframe 
    30713078                // continually check to see if the document is ready 
    3072                 if ( document.documentElement.doScroll && window == window.top ) (function(){ 
    3073                         if ( jQuery.isReady ) return; 
     3079                if ( doc.documentElement.doScroll && win == win.top ) (function(){ 
     3080                        if ( $doc.data( 'isReady' ) ) return; 
    30743081 
    30753082                        try { 
    30763083                                // If IE is used, use the trick by Diego Perini 
    30773084                                // http://javascript.nwbox.com/IEContentLoaded/ 
    3078                                 document.documentElement.doScroll("left"); 
     3085                                doc.documentElement.doScroll("left"); 
    30793086                        } catch( error ) { 
    30803087                                setTimeout( arguments.callee, 0 ); 
    30813088                                return; 
    30823089                        } 
    30833090 
    30843091                        // and execute any waiting functions 
    3085                         jQuery.ready(); 
     3092                        jQuery.ready(doc); 
    30863093                })(); 
    30873094        } 
    30883095 
    30893096        // A fallback to window.onload, that will always work 
    3090         jQuery.event.add( window, "load", jQuery.ready ); 
     3097        jQuery.event.add( win, "load", function () { jQuery.ready(doc); } ); 
    30913098} 
    30923099 
    30933100jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," +