Added a fix for .noConflict(true) not reverting properly. Also added unit tests for...
[jquery.git] / src / event.js
index 6570028..627f4d2 100644 (file)
@@ -267,8 +267,8 @@ jQuery.event = {
                // Calculate pageX/Y if missing and clientX/Y available
                if ( event.pageX == null && event.clientX != null ) {
                        var doc = document.documentElement, body = document.body;
-                       event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0);
-                       event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0);
+                       event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc.clientLeft || 0);
+                       event.pageY = event.clientY + (doc && doc.scrollTop  || body && body.scrollTop  || 0) - (doc.clientLeft || 0);
                }
                        
                // Add which for key events
@@ -430,24 +430,20 @@ function bindReady(){
                document.addEventListener( "DOMContentLoaded", jQuery.ready, false );
        
        // If Safari or IE is used
-       else {
-               // Continually check to see if the document is ready
-               function timer(){
-                       try {
-                               // If IE is used, use the trick by Diego Perini
-                               // http://javascript.nwbox.com/IEContentLoaded/
-                               if ( jQuery.browser.msie || document.readyState != "loaded" && document.readyState != "complete" )
-                                       document.documentElement.doScroll("left");
-       
-                               // and execute any waiting functions
-                               jQuery.ready();
-                       } catch( error ) {
-                               setTimeout( timer, 0 );
-                       }
+       // Continually check to see if the document is ready
+       else (function(){
+               try {
+                       // If IE is used, use the trick by Diego Perini
+                       // http://javascript.nwbox.com/IEContentLoaded/
+                       if ( jQuery.browser.msie || document.readyState != "loaded" && document.readyState != "complete" )
+                               document.documentElement.doScroll("left");
+               } catch( error ) {
+                       return setTimeout( arguments.callee, 0 );
                }
 
-               timer();
-       }
+               // and execute any waiting functions
+               jQuery.ready();
+       })();
 
        // A fallback to window.onload, that will always work
        jQuery.event.add( window, "load", jQuery.ready );