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

Commit 5b79b97

Browse files
committedAug 15, 2017
Destroying scope should only remove its own defaults
1 parent 1796afa commit 5b79b97

7 files changed

+43
-24
lines changed
 

‎dist/ui-leaflet.js

+14-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* ui-leaflet 2.0.0 2016-10-05
2+
* ui-leaflet 2.0.0 2017-08-15
33
* ui-leaflet - An AngularJS directive to easily interact with Leaflet maps
44
* git: https://github.com/angular-ui/ui-leaflet
55
*/
@@ -134,7 +134,7 @@ angular.module('ui-leaflet', ['nemLogging']).directive('leaflet', ["$q", "leafle
134134
});
135135

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

18681868
// Get the _defaults dictionary, and override the properties defined by the user
18691869
return {
1870-
reset: function reset() {
1871-
defaults = {};
1870+
reset: function reset(scopeId) {
1871+
if (!isDefined(scopeId)) {
1872+
scopeId = 'main';
1873+
}
1874+
delete defaults[scopeId];
18721875
},
18731876
getDefaults: function getDefaults(scopeId) {
18741877
var mapId = obtainEffectiveMapId(defaults, scopeId);
@@ -4798,7 +4801,12 @@ angular.module('ui-leaflet').factory('leafletEventsHelpersFactory', ["$rootScope
47984801
// Event propadation logic
47994802
if (isDefined(leafletScope.eventBroadcast[this.lObjectType].logic)) {
48004803
// We take care of possible propagation logic
4801-
if (leafletScope.eventBroadcast[_this.lObjectType].logic !== "emit" && leafletScope.eventBroadcast[_this.lObjectType].logic !== "broadcast") $log.warn(errorHeader + "Available event propagation logic are: 'emit' or 'broadcast'.");
4804+
var configuredLogic = leafletScope.eventBroadcast[_this.lObjectType].logic;
4805+
if (configuredLogic !== "emit" && configuredLogic !== "broadcast") {
4806+
$log.warn(errorHeader + "Available event propagation logic are: 'emit' or 'broadcast'.");
4807+
} else {
4808+
logic = configuredLogic;
4809+
}
48024810
}
48034811
// Enable / Disable
48044812
var eventsEnable = false,
@@ -5050,7 +5058,7 @@ angular.module('ui-leaflet').factory('leafletMarkerEvents', ["$rootScope", "$q",
50505058

50515059
'use strict';
50525060

5053-
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
5061+
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
50545062

50555063
angular.module('ui-leaflet').factory('leafletPathEvents', ["$rootScope", "$q", "leafletLogger", "leafletHelpers", "leafletLabelEvents", "leafletEventsHelpers", function ($rootScope, $q, leafletLogger, leafletHelpers, leafletLabelEvents, leafletEventsHelpers) {
50565064
var isDefined = leafletHelpers.isDefined,

‎dist/ui-leaflet.min.js

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/ui-leaflet.min.no-header.js

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/ui-leaflet_dev_mapped.js

+14-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/ui-leaflet_dev_mapped.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/directives/leaflet.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ angular.module('ui-leaflet', ['nemLogging']).directive('leaflet',
135135
});
136136

137137
scope.$on('$destroy', function () {
138-
leafletMapDefaults.reset();
138+
leafletMapDefaults.reset(attrs.id);
139139
map.remove();
140140
leafletData.unresolveMap(attrs.id);
141141
});

‎src/services/leafletMapDefaults.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,11 @@ angular.module('ui-leaflet').factory('leafletMapDefaults', function ($q, leaflet
4848

4949
// Get the _defaults dictionary, and override the properties defined by the user
5050
return {
51-
reset: function () {
52-
defaults = {};
51+
reset: function (scopeId) {
52+
if (!isDefined(scopeId)){
53+
scopeId = 'main';
54+
}
55+
delete defaults[scopeId];
5356
},
5457
getDefaults: function (scopeId) {
5558
var mapId = obtainEffectiveMapId(defaults, scopeId);

0 commit comments

Comments
 (0)