diff --git a/src/accordion/accordion.js b/src/accordion/accordion.js
index a177931eec..348bd79f9c 100644
--- a/src/accordion/accordion.js
+++ b/src/accordion/accordion.js
@@ -121,8 +121,8 @@ angular.module('ui.bootstrap.accordion', ['ui.bootstrap.collapse'])
link: function(scope, element, attr, controller) {
scope.$watch(function() { return controller[attr.accordionTransclude]; }, function(heading) {
if ( heading ) {
- element.html('');
- element.append(heading);
+ element.find('span').html('');
+ element.find('span').append(heading);
}
});
}
diff --git a/src/accordion/test/accordion.spec.js b/src/accordion/test/accordion.spec.js
index 2b9ae15c59..0a5c4134c6 100644
--- a/src/accordion/test/accordion.spec.js
+++ b/src/accordion/test/accordion.spec.js
@@ -126,10 +126,10 @@ describe('accordion', function () {
describe('with static panels', function () {
beforeEach(function () {
var tpl =
- '' +
- 'Content 1' +
- 'Content 2' +
- '';
+ '' +
+ 'Content 1' +
+ 'Content 2' +
+ '';
element = angular.element(tpl);
$compile(element)(scope);
scope.$digest();
@@ -172,9 +172,9 @@ describe('accordion', function () {
var model;
beforeEach(function () {
var tpl =
- '' +
- '{{group.content}}' +
- '';
+ '' +
+ '{{group.content}}' +
+ '';
element = angular.element(tpl);
model = [
{name: 'title 1', content: 'Content 1'},
@@ -217,10 +217,10 @@ describe('accordion', function () {
describe('is-open attribute', function() {
beforeEach(function () {
var tpl =
- '' +
- 'Content 1' +
- 'Content 2' +
- '';
+ '' +
+ 'Content 1' +
+ 'Content 2' +
+ '';
element = angular.element(tpl);
scope.open = { first: false, second: true };
$compile(element)(scope);
@@ -247,10 +247,10 @@ describe('accordion', function () {
describe('is-open attribute with dynamic content', function() {
beforeEach(function () {
var tpl =
- '' +
- '{{item}}
' +
- 'Static content' +
- '';
+ '' +
+ '{{item}}
' +
+ 'Static content' +
+ '';
element = angular.element(tpl);
scope.items = ['Item 1', 'Item 2', 'Item 3'];
scope.open1 = true;
@@ -274,9 +274,9 @@ describe('accordion', function () {
describe('is-open attribute with dynamic groups', function () {
beforeEach(function () {
var tpl =
- '' +
- '{{group.content}}' +
- '';
+ '' +
+ '{{group.content}}' +
+ '';
element = angular.element(tpl);
scope.groups = [
{name: 'title 1', content: 'Content 1', open: false},
@@ -310,9 +310,9 @@ describe('accordion', function () {
var groupBody;
beforeEach(function () {
var tpl =
- '' +
- 'Content 1' +
- '';
+ '' +
+ 'Content 1' +
+ '';
element = angular.element(tpl);
scope.disabled = true;
$compile(element)(scope);
@@ -340,17 +340,38 @@ describe('accordion', function () {
scope.$digest();
expect(groupBody.scope().isOpen).toBeTruthy();
});
+
+ it('should have text-muted styling', function () {
+ expect(findGroupLink(0).find('span:first')).toHaveClass('text-muted');
+ });
});
+ // This is re-used in both the accordion-heading element and the accordion-heading attribute tests
+ function isDisabledStyleCheck() {
+ var tpl =
+ '' +
+ '' +
+ 'Heading Element {{x}} ' +
+ 'Body' +
+ '' +
+ '';
+ scope.disabled = true;
+ element = $compile(tpl)(scope);
+ scope.$digest();
+ groups = element.find('.panel');
+
+ expect(findGroupLink(0).find('span').hasClass('text-muted')).toBe(true);
+ }
+
describe('accordion-heading element', function() {
beforeEach(function() {
var tpl =
- '' +
- '' +
+ '' +
+ '' +
'Heading Element {{x}} ' +
'Body' +
- '' +
- '';
+ '' +
+ '';
element = $compile(tpl)(scope);
scope.$digest();
groups = element.find('.panel');
@@ -359,20 +380,25 @@ describe('accordion', function () {
expect(findGroupLink(0).text()).toBe('Heading Element 123 ');
});
it('attaches the same scope to the transcluded heading and body', function() {
- expect(findGroupLink(0).find('span').scope().$id).toBe(findGroupBody(0).find('span').scope().$id);
+ expect(findGroupLink(0).find('span.ng-scope').scope().$id).toBe(findGroupBody(0).find('span').scope().$id);
});
+ it('should wrap the transcluded content in a span', function () {
+ expect(findGroupLink(0).find('span:first').length).toEqual(1);
+ });
+
+ it('should have disabled styling when is-disabled is true', isDisabledStyleCheck);
});
describe('accordion-heading attribute', function() {
beforeEach(function() {
var tpl =
- '' +
- '' +
+ '' +
+ '' +
'Heading Element {{x}}
' +
'Body' +
- '' +
- '';
+ '' +
+ '';
element = $compile(tpl)(scope);
scope.$digest();
groups = element.find('.panel');
@@ -381,9 +407,11 @@ describe('accordion', function () {
expect(findGroupLink(0).text()).toBe('Heading Element 123 ');
});
it('attaches the same scope to the transcluded heading and body', function() {
- expect(findGroupLink(0).find('span').scope().$id).toBe(findGroupBody(0).find('span').scope().$id);
+ expect(findGroupLink(0).find('span.ng-scope').scope().$id).toBe(findGroupBody(0).find('span').scope().$id);
});
+ it('should have disabled styling when is-disabled is true', isDisabledStyleCheck);
+
});
describe('accordion-heading, with repeating accordion-groups', function() {