From b9a04a0e9b37c58dc74bdbaac24de7ef3561c3de Mon Sep 17 00:00:00 2001 From: crschmidt Date: Fri, 12 Oct 2007 01:36:12 +0000 Subject: [PATCH] "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 --- lib/OpenLayers/Feature.js | 22 +++++++++++++--------- tests/test_Feature.html | 4 ++-- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/OpenLayers/Feature.js b/lib/OpenLayers/Feature.js index 2004a45591..c068676dae 100644 --- a/lib/OpenLayers/Feature.js +++ b/lib/OpenLayers/Feature.js @@ -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" diff --git a/tests/test_Feature.html b/tests/test_Feature.html index 6023cfb29f..1a33f5f074 100644 --- a/tests/test_Feature.html +++ b/tests/test_Feature.html @@ -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"); }