Make the derivation of the '_contentDivPadding' value safe in the case where the popup is already added to the map's containerDiv. (Closes #1938)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@8980 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2009-03-10 05:14:01 +00:00
parent fe20406714
commit 04dfe9c552

View File

@@ -785,10 +785,13 @@ OpenLayers.Popup = OpenLayers.Class({
//use cached value if we have it
var contentDivPadding = this._contentDivPadding;
if (!contentDivPadding) {
//make the div invisible and add it to the page
this.div.style.display = "none";
document.body.appendChild(this.div);
if (this.div.parentNode == null) {
//make the div invisible and add it to the page
this.div.style.display = "none";
document.body.appendChild(this.div);
}
//read the padding settings from css, put them in an OL.Bounds
contentDivPadding = new OpenLayers.Bounds(
OpenLayers.Element.getStyle(this.contentDiv, "padding-left"),
@@ -799,10 +802,12 @@ OpenLayers.Popup = OpenLayers.Class({
//cache the value
this._contentDivPadding = contentDivPadding;
//remove the div from the page and make it visible again
document.body.removeChild(this.div);
this.div.style.display = "";
if (this.div.parentNode == document.body) {
//remove the div from the page and make it visible again
document.body.removeChild(this.div);
this.div.style.display = "";
}
}
return contentDivPadding;
},