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

git-svn-id: http://svn.openlayers.org/trunk/openlayers@7329 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2008-06-07 15:17:10 +00:00
parent aa486090f1
commit bed7f208ab
2 changed files with 19 additions and 3 deletions

View File

@@ -1365,7 +1365,7 @@ OpenLayers.Util.getBrowserName = function() {
*/
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 @@ OpenLayers.Util.getRenderedDimensions = function(contentHTML, size) {
//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";
}
}

View File

@@ -783,6 +783,20 @@
}
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>
<body>