"In Feature.js the popup is always newly created, instead of reusing the

existing popup.", reported by (and original fix provided by) Bart. Patch
reworked, and tests modified to accomodate for destruction of popup. (Closes
#815) 


git-svn-id: http://svn.openlayers.org/trunk/openlayers@4927 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2007-10-12 01:36:12 +00:00
parent 561f4d6a22
commit b9a04a0e9b
2 changed files with 15 additions and 11 deletions

View File

@@ -179,13 +179,14 @@ OpenLayers.Feature = OpenLayers.Class({
var id = this.id + "_popup";
var anchor = (this.marker) ? this.marker.icon : null;
this.popup = new this.popupClass(id,
this.lonlat,
this.data.popupSize,
this.data.popupContentHTML,
anchor,
closeBox);
if (!this.popup) {
this.popup = new this.popupClass(id,
this.lonlat,
this.data.popupSize,
this.data.popupContentHTML,
anchor,
closeBox);
}
if (this.data.overflow != null) {
this.popup.contentDiv.style.overflow = this.data.overflow;
}
@@ -204,8 +205,11 @@ OpenLayers.Feature = OpenLayers.Class({
* should also be able to override the destruction
*/
destroyPopup: function() {
this.popup.feature = null;
this.popup.destroy()
if (this.popup) {
this.popup.feature = null;
this.popup.destroy();
this.popup = null;
}
},
CLASS_NAME: "OpenLayers.Feature"

View File

@@ -121,7 +121,7 @@
}
function test_04_Feature_createPopup(t) {
t.plan(17);
t.plan(11);
//no lonlat
var f = {
@@ -187,7 +187,7 @@
};
OpenLayers.Feature.prototype.destroyPopup.apply(f, []);
t.ok(f.popup.feature == null, "popup's 'feature' property nullified on destroy");
t.ok(f.popup == null, "popup property nullified on destroy");
}
</script>