diff --git a/lib/OpenLayers/Feature.js b/lib/OpenLayers/Feature.js index 1164a5bfc8..6132023329 100644 --- a/lib/OpenLayers/Feature.js +++ b/lib/OpenLayers/Feature.js @@ -185,6 +185,7 @@ OpenLayers.Feature = OpenLayers.Class({ this.data.popupContentHTML, anchor, closeBox); + this.popup.feature = this; } return this.popup; }, @@ -198,6 +199,7 @@ OpenLayers.Feature = OpenLayers.Class({ * should also be able to override the destruction */ destroyPopup: function() { + this.popup.feature = null; this.popup.destroy() }, diff --git a/tests/test_Feature.html b/tests/test_Feature.html index cd97f5a439..58894a3c5b 100644 --- a/tests/test_Feature.html +++ b/tests/test_Feature.html @@ -105,7 +105,7 @@ } function test_04_Feature_createPopup(t) { - t.plan(15); + t.plan(17); //no lonlat var f = { @@ -144,6 +144,7 @@ ret = OpenLayers.Feature.prototype.createPopup.apply(f, [g_CloseBox]); t.ok((ret == f.popup) && (f.popup != null), "a valid popup has been set and returned") + t.ok( f.popup.feature == f, "popup's 'feature' property correctly set"); //valid lonlat with anchor @@ -154,13 +155,15 @@ g_ExpectedAnchor = f.marker.icon; ret = OpenLayers.Feature.prototype.createPopup.apply(f, [g_CloseBox]); t.ok((ret == f.popup) && (f.popup != null), "a valid popup has been set and returned") + t.ok( f.popup.feature == f, "popup's 'feature' property correctly set"); } function test_04_Feature_destroyPopup(t) { - t.plan(1); + t.plan(2); var f = { 'popup': { + 'feature': {}, 'destroy': function() { t.ok(true, "default destroyPopup() calls popup.destroy"); } @@ -168,6 +171,7 @@ }; OpenLayers.Feature.prototype.destroyPopup.apply(f, []); + t.ok(f.popup.feature == null, "popup's 'feature' property nullified on destroy"); }