OpenLayers OpenLayers

Changeset 7329

Show
Ignore:
Timestamp:
06/07/08 11:17:10 (4 months ago)
Author:
tschaub
Message:

Fixing Util.getRenderedDimensions so it assigns units to positional values. Thanks Wally for the report. r=euzuro (closes #1570)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers/Util.js

    r7311 r7329  
    13661366OpenLayers.Util.getRenderedDimensions = function(contentHTML, size) { 
    13671367     
    1368     var w = h = null
     1368    var w, h
    13691369     
    13701370    // create temp container div with restricted size 
     
    13771377    if (size) { 
    13781378        if (size.w) { 
    1379             w = container.style.width = size.w; 
     1379            w = size.w; 
     1380            container.style.width = w + "px"; 
    13801381        } else if (size.h) { 
    1381             h = container.style.height = size.h; 
     1382            h = size.h 
     1383            container.style.height = h + "px"; 
    13821384        } 
    13831385    } 
  • trunk/openlayers/tests/Util.html

    r7311 r7329  
    783783 
    784784    } 
     785     
     786    function test_getRenderedDimensions(t) { 
     787        t.plan(2); 
     788        var content = (new Array(100)).join("foo "); 
     789         
     790        // test with fixed width 
     791        var fw = OpenLayers.Util.getRenderedDimensions(content, {w: 20}); 
     792        t.eq(fw.w, 20, "got the fixed width"); 
     793         
     794        // test with fixed height 
     795        var fh = OpenLayers.Util.getRenderedDimensions(content, {h: 15}); 
     796        t.eq(fh.h, 15, "got the fixed height"); 
     797         
     798    } 
    785799 
    786800  </script>