diff --git a/src/directives/marker.js b/src/directives/marker.js index e17d1126..5fa0aa0a 100644 --- a/src/directives/marker.js +++ b/src/directives/marker.js @@ -155,6 +155,7 @@ angular.module('openlayers-directive').directive('olMarker', function($log, $q, }; function unregisterHandlers() { + if (!scope.properties) { return ; } // Remove previous listeners if any map.getViewport().removeEventListener('mousemove', scope.properties.handleInteraction); map.getViewport().removeEventListener('click', scope.properties.handleTapInteraction); diff --git a/test/unit/markerSpec.js b/test/unit/markerSpec.js new file mode 100644 index 00000000..d2b839c2 --- /dev/null +++ b/test/unit/markerSpec.js @@ -0,0 +1,23 @@ +'use strict'; +/*jshint -W117 */ +/*jshint globalstrict: true*/ +/* jasmine specs for directives go here */ + +describe('Directive: openlayers marker', function() { + var $compile = null; + var scope; + + beforeEach(module('openlayers-directive')); + beforeEach(inject(function(_$compile_, $rootScope) { + $compile = _$compile_; + + scope = $rootScope.$new(); + })); + + it('should not error on $scope.$destroy', function() { + var element = angular.element(''); + element = $compile(element)(scope); + scope.$digest(); + expect(function() { scope.$destroy(); }).not.toThrow(); + }); +});