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:
@@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user