diff --git a/src/modal/modal.js b/src/modal/modal.js index 106b988a71..a6cafcce75 100644 --- a/src/modal/modal.js +++ b/src/modal/modal.js @@ -272,7 +272,7 @@ angular.module('ui.bootstrap.modal', []) openedWindows.remove(modalInstance); removeAfterAnimate(modalWindow.modalDomEl, modalWindow.modalScope, function() { - body.toggleClass(modalInstance.openedClass || OPENED_MODAL_CLASS, openedWindows.length() > 0); + body.toggleClass(modalWindow.openedClass || OPENED_MODAL_CLASS, openedWindows.length() > 0); }); checkRemoveBackdrop(); diff --git a/src/modal/test/modal.spec.js b/src/modal/test/modal.spec.js index 2be1b7c969..0b6abb8640 100644 --- a/src/modal/test/modal.spec.js +++ b/src/modal/test/modal.spec.js @@ -768,13 +768,18 @@ describe('$modal', function () { }); describe('openedClass', function () { + var body; + + beforeEach(function() { + body = $document.find('body'); + }); it('should add the modal-open class to the body element by default', function () { open({ template: '
dummy modal
' }); - expect($document.find('body')).toHaveClass('modal-open'); + expect(body).toHaveClass('modal-open'); }); it('should add the custom class to the body element', function () { @@ -783,11 +788,22 @@ describe('$modal', function () { openedClass: 'foo' }); - var body = $document.find('body'); - expect(body).toHaveClass('foo'); expect(body).not.toHaveClass('modal-open'); }); + + it('should remove the custom class on closing of modal', function () { + var modal = open({ + template: '
dummy modal
', + openedClass: 'foo' + }); + + expect(body).toHaveClass('foo'); + + close(modal); + + expect(body).not.toHaveClass('foo'); + }); }); });