Skip to content
This repository has been archived by the owner on Sep 20, 2019. It is now read-only.

Commit

Permalink
Destroying scope should only remove its own defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
eugenehuangsg committed Dec 7, 2017
1 parent ff994d4 commit 363b586
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 22 deletions.
18 changes: 13 additions & 5 deletions dist/ui-leaflet.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* ui-leaflet 2.0.0 2016-10-21
* ui-leaflet 2.0.0 2017-08-15
* ui-leaflet - An AngularJS directive to easily interact with Leaflet maps
* git: https://github.com/angular-ui/ui-leaflet
*/
Expand Down Expand Up @@ -134,7 +134,7 @@ angular.module('ui-leaflet', ['nemLogging']).directive('leaflet', ["$q", "leafle
});

scope.$on('$destroy', function () {
leafletMapDefaults.reset();
leafletMapDefaults.reset(attrs.id);
map.remove();
leafletData.unresolveMap(attrs.id);
});
Expand Down Expand Up @@ -1867,8 +1867,11 @@ angular.module('ui-leaflet').factory('leafletMapDefaults', ["$q", "leafletHelper

// Get the _defaults dictionary, and override the properties defined by the user
return {
reset: function reset() {
defaults = {};
reset: function reset(scopeId) {
if (!isDefined(scopeId)) {
scopeId = 'main';
}
delete defaults[scopeId];
},
getDefaults: function getDefaults(scopeId) {
var mapId = obtainEffectiveMapId(defaults, scopeId);
Expand Down Expand Up @@ -4802,7 +4805,12 @@ angular.module('ui-leaflet').factory('leafletEventsHelpersFactory', ["$rootScope
// Event propadation logic
if (isDefined(leafletScope.eventBroadcast[this.lObjectType].logic)) {
// We take care of possible propagation logic
if (leafletScope.eventBroadcast[_this.lObjectType].logic !== "emit" && leafletScope.eventBroadcast[_this.lObjectType].logic !== "broadcast") $log.warn(errorHeader + "Available event propagation logic are: 'emit' or 'broadcast'.");
var configuredLogic = leafletScope.eventBroadcast[_this.lObjectType].logic;
if (configuredLogic !== "emit" && configuredLogic !== "broadcast") {
$log.warn(errorHeader + "Available event propagation logic are: 'emit' or 'broadcast'.");
} else {
logic = configuredLogic;
}
}
// Enable / Disable
var eventsEnable = false,
Expand Down
8 changes: 4 additions & 4 deletions dist/ui-leaflet.min.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions dist/ui-leaflet.min.no-header.js

Large diffs are not rendered by default.

18 changes: 13 additions & 5 deletions dist/ui-leaflet_dev_mapped.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/ui-leaflet_dev_mapped.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/directives/leaflet.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ angular.module('ui-leaflet', ['nemLogging']).directive('leaflet',
});

scope.$on('$destroy', function () {
leafletMapDefaults.reset();
leafletMapDefaults.reset(attrs.id);
map.remove();
leafletData.unresolveMap(attrs.id);
});
Expand Down
7 changes: 5 additions & 2 deletions src/services/leafletMapDefaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ angular.module('ui-leaflet').factory('leafletMapDefaults', function ($q, leaflet

// Get the _defaults dictionary, and override the properties defined by the user
return {
reset: function () {
defaults = {};
reset: function (scopeId) {
if (!isDefined(scopeId)){
scopeId = 'main';
}
delete defaults[scopeId];
},
getDefaults: function (scopeId) {
var mapId = obtainEffectiveMapId(defaults, scopeId);
Expand Down

0 comments on commit 363b586

Please sign in to comment.