Merge pull request #1446 from jfirebaugh/unload
Fire an unload event on removal
This commit is contained in:
commit
f0a75c9d08
@ -7,6 +7,22 @@ describe("Map", function () {
|
||||
});
|
||||
|
||||
describe("#remove", function () {
|
||||
it("fires an unload event if loaded", function () {
|
||||
var container = document.createElement('div'),
|
||||
map = new L.Map(container).setView([0, 0], 0);
|
||||
map.on('unload', spy);
|
||||
map.remove();
|
||||
expect(spy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("fires no unload event if not loaded", function () {
|
||||
var container = document.createElement('div'),
|
||||
map = new L.Map(container);
|
||||
map.on('unload', spy);
|
||||
map.remove();
|
||||
expect(spy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("undefines container._leaflet", function () {
|
||||
var container = document.createElement('div'),
|
||||
map = new L.Map(container);
|
||||
|
@ -240,6 +240,9 @@ L.Map = L.Class.extend({
|
||||
},
|
||||
|
||||
remove: function () {
|
||||
if (this._loaded) {
|
||||
this.fire('unload');
|
||||
}
|
||||
this._initEvents('off');
|
||||
delete this._container._leaflet;
|
||||
return this;
|
||||
|
Loading…
Reference in New Issue
Block a user