OpenLayers OpenLayers

Ticket #1570: grd.patch

File grd.patch, 1.6 kB (added by tschaub, 7 months ago)

use units when setting style width and height

  • tests/Util.html

    old new  
    770770        t.ok(ret == g_TestVal3, "try returns first sucessfully executed function's return"); 
    771771 
    772772    } 
     773     
     774    function test_getRenderedDimensions(t) { 
     775        t.plan(2); 
     776        var content = (new Array(100)).join("foo "); 
     777         
     778        // test with fixed width 
     779        var fw = OpenLayers.Util.getRenderedDimensions(content, {w: 20}); 
     780        t.eq(fw.w, 20, "got the fixed width"); 
     781         
     782        // test with fixed height 
     783        var fh = OpenLayers.Util.getRenderedDimensions(content, {h: 15}); 
     784        t.eq(fh.h, 15, "got the fixed height"); 
     785         
     786    } 
    773787 
    774788  </script> 
    775789</head> 
  • lib/OpenLayers/Util.js

    old new  
    13641364 */ 
    13651365OpenLayers.Util.getRenderedDimensions = function(contentHTML, size) { 
    13661366     
    1367     var w = h = null
     1367    var w, h
    13681368     
    13691369    // create temp container div with restricted size 
    13701370    var container = document.createElement("div"); 
     
    13751375    //fix a dimension, if specified. 
    13761376    if (size) { 
    13771377        if (size.w) { 
    1378             w = container.style.width = size.w; 
     1378            w = size.w; 
     1379            container.style.width = w + "px"; 
    13791380        } else if (size.h) { 
    1380             h = container.style.height = size.h; 
     1381            h = size.h 
     1382            container.style.height = h + "px"; 
    13811383        } 
    13821384    } 
    13831385