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

Commit

Permalink
fix(datepicker): remove datepicker's popup on scope destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-dedukhin authored and bekos committed Dec 16, 2013
1 parent 41bea46 commit 48955d6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/datepicker/datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ function ($compile, $parse, $document, $position, dateFilter, datepickerPopupCon
scope.showButtonBar = angular.isDefined(attrs.showButtonBar) ? originalScope.$eval(attrs.showButtonBar) : datepickerPopupConfig.showButtonBar;

originalScope.$on('$destroy', function() {
$popup.remove();
scope.$destroy();
});

Expand Down
13 changes: 13 additions & 0 deletions src/datepicker/test/datepicker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,19 @@ describe('datepicker directive', function () {
expect($body.children().length).toEqual(bodyLength + 1);
expect(elm.children().length).toEqual(1);
});
it('should be removed on scope destroy', function() {
var $body = $document.find('body'),
bodyLength = $body.children().length,
isolatedScope = $rootScope.$new(),
elm = angular.element(
'<input datepicker-popup ng-model="date" datepicker-append-to-body="true"></input>'
);
$compile(elm)(isolatedScope);
isolatedScope.$digest();
expect($body.children().length).toEqual(bodyLength + 1);
isolatedScope.$destroy();
expect($body.children().length).toEqual(bodyLength);
});
});

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

0 comments on commit 48955d6

Please sign in to comment.