From 0917623b1844b69988a6f1b0b8ec59fefcb759fe Mon Sep 17 00:00:00 2001 From: Chenyu Zhang Date: Tue, 10 Nov 2015 16:08:20 -0500 Subject: [PATCH] fix(accordion): ensure panelOpen class is present - Ensure panelOpen class is present on initialization of panel Closes #4849 Closes #4870 --- src/accordion/accordion.js | 2 +- src/accordion/test/accordion.spec.js | 23 +++++++++++++++++++++++ template/accordion/accordion-group.html | 2 +- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/accordion/accordion.js b/src/accordion/accordion.js index e6c2e96dc9..e44cb2d1bb 100644 --- a/src/accordion/accordion.js +++ b/src/accordion/accordion.js @@ -76,7 +76,7 @@ angular.module('ui.bootstrap.accordion', ['ui.bootstrap.collapse']) accordionCtrl.addGroup(scope); scope.openClass = attrs.openClass || 'panel-open'; - scope.panelClass = attrs.panelClass; + scope.panelClass = attrs.panelClass || 'panel-default'; scope.$watch('isOpen', function(value) { element.toggleClass(scope.openClass, !!value); if (value) { diff --git a/src/accordion/test/accordion.spec.js b/src/accordion/test/accordion.spec.js index 31dd983ef5..f80e7e1453 100644 --- a/src/accordion/test/accordion.spec.js +++ b/src/accordion/test/accordion.spec.js @@ -426,6 +426,29 @@ describe('uib-accordion', function() { }); }); + describe('is-open attribute with custom class', function() { + beforeEach(function() { + var tpl = + '' + + '{{group.content}}' + + ''; + element = angular.element(tpl); + scope.groups = [ + {name: 'title 1', content: 'Content 1', open: false}, + {name: 'title 2', content: 'Content 2', open: true} + ]; + $compile(element)(scope); + scope.$digest(); + + groups = element.find('.panel'); + }); + + it('should add "panel-open" class', function(){ + expect(groups.eq(0)).not.toHaveClass('panel-open'); + expect(groups.eq(1)).toHaveClass('panel-open'); + }); + }); + describe('`is-disabled` attribute', function() { var groupBody; beforeEach(function() { diff --git a/template/accordion/accordion-group.html b/template/accordion/accordion-group.html index d5b8a256e2..c9edcbba3e 100644 --- a/template/accordion/accordion-group.html +++ b/template/accordion/accordion-group.html @@ -1,4 +1,4 @@ -
+

{{heading}}