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

commits at openlayers.org commits at openlayers.org
Sat Jun 7 11:17:10 EDT 2008


Author: tschaub
Date: 2008-06-07 11:17:10 -0400 (Sat, 07 Jun 2008)
New Revision: 7329

Modified:
   trunk/openlayers/lib/OpenLayers/Util.js
   trunk/openlayers/tests/Util.html
Log:
Fixing Util.getRenderedDimensions so it assigns units to positional values.  Thanks Wally for the report.  r=euzuro (closes #1570)

Modified: trunk/openlayers/lib/OpenLayers/Util.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Util.js	2008-06-06 20:20:12 UTC (rev 7328)
+++ trunk/openlayers/lib/OpenLayers/Util.js	2008-06-07 15:17:10 UTC (rev 7329)
@@ -1365,7 +1365,7 @@
  */
 OpenLayers.Util.getRenderedDimensions = function(contentHTML, size) {
     
-    var w = h = null;
+    var w, h;
     
     // create temp container div with restricted size
     var container = document.createElement("div");
@@ -1376,9 +1376,11 @@
     //fix a dimension, if specified.
     if (size) {
         if (size.w) {
-            w = container.style.width = size.w;
+            w = size.w;
+            container.style.width = w + "px";
         } else if (size.h) {
-            h = container.style.height = size.h;
+            h = size.h
+            container.style.height = h + "px";
         }
     }
     

Modified: trunk/openlayers/tests/Util.html
===================================================================
--- trunk/openlayers/tests/Util.html	2008-06-06 20:20:12 UTC (rev 7328)
+++ trunk/openlayers/tests/Util.html	2008-06-07 15:17:10 UTC (rev 7329)
@@ -782,6 +782,20 @@
         t.ok(ret == g_TestVal3, "try returns first sucessfully executed function's return");
 
     }
+    
+    function test_getRenderedDimensions(t) {
+        t.plan(2);
+        var content = (new Array(100)).join("foo ");
+        
+        // test with fixed width
+        var fw = OpenLayers.Util.getRenderedDimensions(content, {w: 20});
+        t.eq(fw.w, 20, "got the fixed width");
+        
+        // test with fixed height
+        var fh = OpenLayers.Util.getRenderedDimensions(content, {h: 15});
+        t.eq(fh.h, 15, "got the fixed height");
+        
+    }
 
   </script>
 </head>



More information about the Commits mailing list