diff --git a/src/accordion/accordion.js b/src/accordion/accordion.js index f0b4748799..8674f535a1 100644 --- a/src/accordion/accordion.js +++ b/src/accordion/accordion.js @@ -64,6 +64,7 @@ angular.module('ui.bootstrap.accordion', ['ui.bootstrap.collapse']) }, scope: { heading: '@', // Interpolate the heading attribute onto this scope + panelClass: '@?', // Ditto with panelClass isOpen: '=?', isDisabled: '=?' }, diff --git a/src/accordion/docs/readme.md b/src/accordion/docs/readme.md index e176d8fde2..ff72bf8a62 100644 --- a/src/accordion/docs/readme.md +++ b/src/accordion/docs/readme.md @@ -33,6 +33,7 @@ The body of each accordion group is transcluded into the body of the collapsible Whether accordion group is open or closed. * `panel-class` + _(Default: `panel-default`)_ - Add ability to use Bootstrap's contextual panel classes (panel-primary, panel-success, panel-info, etc...) or your own. This must be a string. diff --git a/src/accordion/test/accordion.spec.js b/src/accordion/test/accordion.spec.js index abbf83691e..9916f1e045 100644 --- a/src/accordion/test/accordion.spec.js +++ b/src/accordion/test/accordion.spec.js @@ -610,8 +610,8 @@ describe('uib-accordion', function() { }); }); - describe('uib-accordion group panel class - #3968', function() { - it('should use the default value when panel class is falsy', function() { + describe('uib-accordion group panel class', function() { + it('should use the default value when panel class is falsy - #3968', function() { element = $compile('Content')(scope); scope.$digest(); groups = element.find('.panel'); @@ -623,13 +623,26 @@ describe('uib-accordion', function() { expect(groups.eq(0)).toHaveClass('panel-default'); }); - it('should use the specified value when not falsy', function() { + it('should use the specified value when not falsy - #3968', function() { element = $compile('Content')(scope); scope.$digest(); groups = element.find('.panel'); expect(groups.eq(0)).toHaveClass('custom-class'); expect(groups.eq(0)).not.toHaveClass('panel-default'); }); + + it('should change class if panel-class is changed', function() { + element = $compile('Content')(scope); + scope.panelClass = 'custom-class'; + scope.$digest(); + groups = element.find('.panel'); + expect(groups.eq(0)).toHaveClass('custom-class'); + + scope.panelClass = 'different-class'; + scope.$digest(); + expect(groups.eq(0)).toHaveClass('different-class'); + expect(groups.eq(0)).not.toHaveClass('custom-class'); + }); }); }); });