[OpenLayers-Commits] r4783 - in trunk/openlayers: lib/OpenLayers tests

commits at openlayers.org commits at openlayers.org
Wed Oct 3 12:15:48 EDT 2007


Author: crschmidt
Date: 2007-10-03 12:15:43 -0400 (Wed, 03 Oct 2007)
New Revision: 4783

Modified:
   trunk/openlayers/lib/OpenLayers/Util.js
   trunk/openlayers/tests/test_Util.html
Log:
IE thinks that window and document.body are really the same thing -- even
though one has a style property and the other doesn't. This means that when
we pass in 'window' to pagePosition, it blows up, but it didin't before a 
recent reorganization. Here, we create a short term preventative measure to
ensure that old apps don't break -- this should be fixed in 2.6. 
(See #1034, #1051)


Modified: trunk/openlayers/lib/OpenLayers/Util.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Util.js	2007-10-03 16:11:19 UTC (rev 4782)
+++ trunk/openlayers/lib/OpenLayers/Util.js	2007-10-03 16:15:43 UTC (rev 4783)
@@ -991,7 +991,12 @@
     while(element) {
 
         if(element == document.body) {
-            if(OpenLayers.Element.getStyle(child, 'position') == 'absolute') {
+            // FIXME: IE, when passed 'window' as the forElement, treats it as
+            // equal to document.body, but window.style fails, so getStyle
+            // fails, so we are paranoid and check this here. This check should
+            // probably move into element.getStyle in 2.6.
+            if(child && child.style && 
+               OpenLayers.Element.getStyle(child, 'position') == 'absolute') {
                 break;
             }
         }

Modified: trunk/openlayers/tests/test_Util.html
===================================================================
--- trunk/openlayers/tests/test_Util.html	2007-10-03 16:11:19 UTC (rev 4782)
+++ trunk/openlayers/tests/test_Util.html	2007-10-03 16:15:43 UTC (rev 4783)
@@ -19,6 +19,13 @@
         OpenLayers.Util.removeItem(array, 3);
         t.eq( array.toString(), "1,2,4,5", "Util.removeItem works");    
     }
+    
+    function test_03_Util_pagePosition(t) {
+        t.plan( 1 );
+        var pp = OpenLayers.Util.pagePosition(window);
+        t.eq( pp.toString(), "0,0", "Page position doesn't bail if passed 'window'")
+        
+    }
 
     function test_04_Util_createDiv(t) {
         t.plan( 24 );



More information about the Commits mailing list