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

Commit 48955d6

Browse files
dmitry-dedukhinbekos
authored andcommittedDec 16, 2013
fix(datepicker): remove datepicker's popup on scope destroy
1 parent 41bea46 commit 48955d6

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed
 

‎src/datepicker/datepicker.js

+1
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ function ($compile, $parse, $document, $position, dateFilter, datepickerPopupCon
281281
scope.showButtonBar = angular.isDefined(attrs.showButtonBar) ? originalScope.$eval(attrs.showButtonBar) : datepickerPopupConfig.showButtonBar;
282282

283283
originalScope.$on('$destroy', function() {
284+
$popup.remove();
284285
scope.$destroy();
285286
});
286287

‎src/datepicker/test/datepicker.spec.js

+13
Original file line numberDiff line numberDiff line change
@@ -1298,6 +1298,19 @@ describe('datepicker directive', function () {
12981298
expect($body.children().length).toEqual(bodyLength + 1);
12991299
expect(elm.children().length).toEqual(1);
13001300
});
1301+
it('should be removed on scope destroy', function() {
1302+
var $body = $document.find('body'),
1303+
bodyLength = $body.children().length,
1304+
isolatedScope = $rootScope.$new(),
1305+
elm = angular.element(
1306+
'<input datepicker-popup ng-model="date" datepicker-append-to-body="true"></input>'
1307+
);
1308+
$compile(elm)(isolatedScope);
1309+
isolatedScope.$digest();
1310+
expect($body.children().length).toEqual(bodyLength + 1);
1311+
isolatedScope.$destroy();
1312+
expect($body.children().length).toEqual(bodyLength);
1313+
});
13011314
});
13021315

13031316
describe('with setting datepickerConfig.showWeeks to false', function() {

0 commit comments

Comments
 (0)