Making it safe to destroy a permalink.

Previously, a map could not be destroyed if it included a permalink control without an "element".  In addition, a permalink control could not be destroyed if it didn't have a reference to a map.
This commit is contained in:
Tim Schaub
2012-03-03 14:42:43 -07:00
parent 935d621113
commit 9a3b723ba4
2 changed files with 26 additions and 6 deletions

View File

@@ -94,12 +94,13 @@ OpenLayers.Control.Permalink = OpenLayers.Class(OpenLayers.Control, {
* APIMethod: destroy
*/
destroy: function() {
if (this.element.parentNode == this.div) {
if (this.element && this.element.parentNode == this.div) {
this.div.removeChild(this.element);
this.element = null;
}
if (this.map) {
this.map.events.unregister('moveend', this, this.updateLink);
}
this.element = null;
this.map.events.unregister('moveend', this, this.updateLink);
OpenLayers.Control.prototype.destroy.apply(this, arguments);
},