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

feat(accordion): panel-class now responds to change. #5596

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/accordion/accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to @? - should be optional

isOpen: '=?',
isDisabled: '=?'
},
Expand Down
3 changes: 2 additions & 1 deletion src/accordion/docs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ The body of each accordion group is transcluded into the body of the collapsible
Whether accordion group is open or closed.

* `panel-class`
<i class="glyphicon glyphicon-eye-open"></i>
_(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.
Add ability to use Bootstrap's contextual panel classes (panel-primary, panel-success, panel-info, etc...) or your own. This must be a string.

* `template-url`
_(Default: `uib/template/accordion/accordion-group.html`)_ -
Expand Down
19 changes: 16 additions & 3 deletions src/accordion/test/accordion.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('<uib-accordion><uib-accordion-group heading="Heading">Content</uib-accordion-group></uib-accordion>')(scope);
scope.$digest();
groups = element.find('.panel');
Expand All @@ -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('<uib-accordion><uib-accordion-group heading="Heading" panel-class="custom-class">Content</uib-accordion-group></uib-accordion>')(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('<uib-accordion><uib-accordion-group heading="Heading" panel-class="{{panelClass}}">Content</uib-accordion-group></uib-accordion>')(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');
});
});
});
});